Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2005, 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 /
 
 package org.eclipse.jdt.internal.codeassist;
 
Internal completion context

Since:
3.1
 
 public class InternalCompletionContext extends CompletionContext {
 	protected char[][] expectedTypesSignatures;
 	protected char[][] expectedTypesKeys;
 	protected int javadoc;
 
 	protected int offset = -1;
 	protected int tokenStart = -1;
 	protected int tokenEnd = -1;
 	protected char[] token = null;
 	protected int tokenKind;
 	protected int tokenLocation;
 
 	protected boolean isExtended;
 
 	protected void setExpectedTypesKeys(char[][] expectedTypesKeys) {
 		this. = expectedTypesKeys;
 	}
 
 	protected void setExpectedTypesSignatures(char[][] expectedTypesSignatures) {
 		this. = expectedTypesSignatures;
 	}
 
 	protected void setExtended() {
 		this. = true;
 	}
 
 	protected void setExtendedData(
 			ITypeRoot typeRoot,
 			CompilationUnitDeclaration compilationUnitDeclaration,
 			LookupEnvironment lookupEnvironment,
 			Scope scope,
 			ASTNode astNode,
 			ASTNode astNodeParent,
 			CompletionParser parser) {
 		this. = true;
 					this,
 					typeRoot,
 					compilationUnitDeclaration,
 					lookupEnvironment,
 					scope,
 					astNode,
 					astNodeParent,
 					owner,
 					parser);
 	}
 
 	protected void setJavadoc(int javadoc) {
 		this. = javadoc;
 	}
 
 	protected void setOffset(int offset) {
 		this. = offset;
 	}
 
 	protected void setToken(char[] token) {
 		this. = token;
 	}
	protected void setTokenKind(int tokenKind) {
		this. = tokenKind;
	}
	protected void setTokenLocation(int tokenLocation) {
		this. = tokenLocation;
	}
	protected void setTokenRange(int startint end) {
		this.setTokenRange(startend, -1);
	}
	protected void setTokenRange(int startint endint endOfEmptyToken) {
		this. = start;
		this. = endOfEmptyToken > end ? endOfEmptyToken : end;
		// 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. == -1) {
			this. = 0;
		}
	}

Returns the innermost enclosing Java element which contains the completion location or null if this element cannot be computed. The returned Java element and all Java elements in the same compilation unit which can be navigated to from the returned Java element are special Java elements:
  • they are based on the current content of the compilation unit's buffer, they are not the result of a reconcile operation
  • they are not updated if the buffer changes.
  • they do not contain local types which are not visible from the completion location.
  • they do not give information about categories. org.eclipse.jdt.core.IMember.getCategories() will return an empty array
Reasons for returning null include:
  • the compilation unit no longer exists
  • the completion occurred in a binary type. However this restriction might be relaxed in the future.

Returns:
the innermost enclosing Java element which contains the completion location or null if this element cannot be computed.
Throws:
java.lang.UnsupportedOperationException if the context is not an extended context
Since:
3.4
		if (!this.throw new UnsupportedOperationException("Operation only supported in extended context"); //$NON-NLS-1$
		if (this. == nullreturn null;
	}

Return keys of expected types of a potential completion proposal at the completion position. It's not mandatory to a completion proposal to respect this expectation.

Returns:
keys of expected types of a potential completion proposal at the completion position or null if there is no expected types.
See also:
org.eclipse.jdt.core.dom.ASTParser#createASTs(ICompilationUnit[] , String[] , org.eclipse.jdt.core.dom.ASTRequestor , org.eclipse.core.runtime.IProgressMonitor )
	public char[][] getExpectedTypesKeys() {
		return this.;
	}

Return signatures of expected types of a potential completion proposal at the completion position. It's not mandatory to a completion proposal to respect this expectation.

Returns:
signatures expected types of a potential completion proposal at the completion position or null if there is no expected types.
See also:
org.eclipse.jdt.core.Signature
	public char[][] getExpectedTypesSignatures() {
	}

Returns the offset position in the source file buffer after which code assist is requested.

Returns:
offset position in the source file buffer
Since:
3.2
	public int getOffset() {
		return this.;
	}

Returns the completed token. This token is either the identifier or Java language keyword or the string literal under, immediately preceding, the original request offset. If the original request offset is not within or immediately after an identifier or keyword or a string literal then the returned value is null.

Returns:
completed token or null
Since:
3.2
	public char[] getToken() {
		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 (getTokenEnd() == getTokenStart() - 1).

Returns:
character index of token end position (exclusive)
Since:
3.2
	// TODO (david) https://bugs.eclipse.org/bugs/show_bug.cgi?id=132558
	public int getTokenEnd() {
		return this.;
	}

Returns the kind of completion token being proposed.

The set of different kinds of completion token 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 whose name starts with TOKEN_KIND, or possibly a kind unknown to the caller
Since:
3.2
	public int getTokenKind() {
		return this.;
	}

Returns the location of completion token being proposed. The returned location is a bit mask which can contain some values of the constants declared on this class whose name starts with TL, or possibly values unknown to the caller.

The set of different location values is expected to change over time. It is strongly recommended that clients do not assume that the location contains only known value, and code defensively for the possibility of unexpected future growth.

Returns:
the location
Since:
3.4
	public int getTokenLocation() {
		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)
Since:
3.2
	public int getTokenStart() {
		return this.;
	}

Return the elements which are visible from the completion location and which can be assigned to the given type. An element is assignable if its type can be assigned to a variable of the given type, as specified in section 5.2 of The Java Language Specification, Third Edition (JLS3). A visible element is either: Returned elements defined in the completed compilation unit are special Java elements:
  • they are based on the current content of the compilation unit's buffer, they are not the result of a reconcile operation
  • they are not updated if the buffer changes.
  • they do not contain local types which are not visible from the completion location.
  • they do not give information about categories. org.eclipse.jdt.core.IMember.getCategories() will return an empty array
Note the array can be empty if:
  • the compilation unit no longer exists
  • the completion occurred in a binary type. However this restriction might be relaxed in the future.

Parameters:
typeSignature elements which can be assigned to this type are returned. If null there is no constraint on the type of the returned elements.
Returns:
elements which are visible from the completion location and which can be assigned to the given type.
Throws:
java.lang.UnsupportedOperationException if the context is not an extended context
Since:
3.4
See also:
isExtended()
	public IJavaElement[] getVisibleElements(String typeSignature) {
		if (!this.throw new UnsupportedOperationException("Operation only supported in extended context"); //$NON-NLS-1$
		if (this. == nullreturn new IJavaElement[0];
		return this..getVisibleElements(typeSignature);
	}

Returns whether this completion context is an extended context. Some methods of this context can be used only if this context is an extended context but an extended context consumes more memory.

Returns:
true if this completion context is an extended context.
Since:
3.4
	public boolean isExtended() {
		return this.;
	}

Tell user whether completion takes place in a javadoc comment or not.

Returns:
boolean true if completion takes place in a javadoc comment, false otherwise.
Since:
3.2
	public boolean isInJavadoc() {
		return this. != 0;
	}

Tell user whether completion takes place in a formal reference of a javadoc tag or not. Tags with formal reference are:
  • @see
  • @throws
  • @exception
  • {@link Object}
  • {@linkplain Object}
  • {@value} when compiler compliance is set at leats to 1.5

Returns:
boolean true if completion takes place in formal reference of a javadoc tag, false otherwise.
Since:
3.2
	public boolean isInJavadocFormalReference() {
		return (this. & .) != 0;
	}

Tell user whether completion takes place in text area of a javadoc comment or not.

Returns:
boolean true if completion takes place in a text area of a javadoc comment, false otherwise.
Since:
3.2
	public boolean isInJavadocText() {
		return (this. & .) != 0;
	}

Return the completion node associated with the current completion.

Returns:
completion AST node, or null if the extendedContext is null.
Throws:
java.lang.UnsupportedOperationException if the context is not an extended context
See also:
isExtended()
		if (!this.throw new UnsupportedOperationException("Operation only supported in extended context"); //$NON-NLS-1$
		if (this. == nullreturn null;
	}

Return the parent AST node of the completion node associated with the current completion.

Returns:
completion parent AST node, or null if the extendedContext is null.
Throws:
java.lang.UnsupportedOperationException if the context is not an extended context
See also:
isExtended()
		if (!this.throw new UnsupportedOperationException("Operation only supported in extended context"); //$NON-NLS-1$
		if (this. == nullreturn null;
	}

Return the bindings of all visible local variables in the current completion context.

Returns:
bindings of all visible local variables, or null if the extendedContext is null. Returned bindings are instances of org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding
Throws:
java.lang.UnsupportedOperationException if the context is not an extended context
See also:
isExtended()
		if (!this.throw new UnsupportedOperationException("Operation only supported in extended context"); //$NON-NLS-1$
		if (this. == nullreturn null;
	}

Return the bindings of all visible fields in the current completion context.

Returns:
bindings of all visible fields, or null if the extendedContext is null. Returned bindings are instances of org.eclipse.jdt.internal.compiler.lookup.FieldBinding
Throws:
java.lang.UnsupportedOperationException if the context is not an extended context
See also:
isExtended()
		if (!this.throw new UnsupportedOperationException("Operation only supported in extended context"); //$NON-NLS-1$
		if (this. == nullreturn null;
	}

Return the bindings of all visible methods in the current completion context.

Returns:
bindings of all visible methods, or null if the extendedContext is null. Returned bindings are instances of org.eclipse.jdt.internal.compiler.lookup.MethodBinding
Throws:
java.lang.UnsupportedOperationException if the context is not an extended context
See also:
isExtended()
		if (!this.throw new UnsupportedOperationException("Operation only supported in extended context"); //$NON-NLS-1$
		if (this. == nullreturn null;
	}
New to GrepCode? Check out our FAQ X