Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2000, 2009 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.complete;
 
Node representing a Javadoc comment including code selection.
 
 public class CompletionJavadoc extends Javadoc {
 
 
 	public CompletionJavadoc(int sourceStartint sourceEnd) {
 		super(sourceStartsourceEnd);
 	}

Returns:
Returns the completionNode.
 
 		return this.;
 	}

Resolve selected node if not null and throw exception to let clients know that it has been found.

 
 	private void internalResolve(Scope scope) {
 		if (this. != null) {
 			if (this. instanceof CompletionOnJavadocTag) {
 			} else {
 				boolean resolve = true;
 				} else if (this. instanceof CompletionOnJavadocTypeParamReference) {
 				}
 				if (resolve) {
 					switch (scope.kind) {
 							break;
 							break;
 					}
 				}
 					if (scope.kind == .) {
 						paramNameReference.missingParams = missingParamTags(paramNameReference.binding, (MethodScope)scope);
 					}
 					if (paramNameReference.token == null || paramNameReference.token.length == 0) {
 						paramNameReference.missingTypeParams = missingTypeParameterTags(paramNameReference.bindingscope);
 					}
 				} else if (this. instanceof CompletionOnJavadocTypeParamReference) {
 					typeParamReference.missingParams = missingTypeParameterTags(typeParamReference.resolvedTypescope);
 				}
 			}
 			Binding qualifiedBinding = null;
 				if (typeRef.packageBinding == null) {
 					qualifiedBinding = typeRef.resolvedType;
 				} else {
 					qualifiedBinding = typeRef.packageBinding;
 				}
 			} else if (this. instanceof CompletionOnJavadocMessageSend) {
 				if (!msg.receiver.isThis()) qualifiedBinding = msg.receiver.resolvedType;
 			} else if (this. instanceof CompletionOnJavadocAllocationExpression) {
 				qualifiedBinding = alloc.type.resolvedType;
 			}
 			throw new CompletionNodeFound(this.qualifiedBindingscope);
 		}
 	}
 
 	/*
 	 * @see org.eclipse.jdt.internal.compiler.ast.ASTNode#print(int, java.lang.StringBuffer)
 	 */
 	public StringBuffer print(int indentStringBuffer output) {
 		printIndent(indentoutput).append("/**\n"); //$NON-NLS-1$
 		boolean nodePrinted = false;
 		if (this. != null) {
			for (int i = 0, length = this..lengthi < lengthi++) {
				printIndent(indentoutput).append(" * @param "); //$NON-NLS-1$
				this.[i].print(indentoutput).append('\n');
				if (!nodePrinted && this. != null) {
					nodePrinted =  this. == this.[i];
				}
			}
		}
		if (this. != null) {
			for (int i = 0, length = this..lengthi < lengthi++) {
				printIndent(indentoutput).append(" * @param <"); //$NON-NLS-1$
				this.[i].print(indentoutput).append(">\n"); //$NON-NLS-1$
				if (!nodePrinted && this. != null) {
					nodePrinted =  this. == this.[i];
				}
			}
		}
		if (this. != null) {
			printIndent(indentoutput).append(" * @"); //$NON-NLS-1$
			this..print(indentoutput).append('\n');
		}
		if (this. != null) {
			for (int i = 0, length = this..lengthi < lengthi++) {
				printIndent(indentoutput).append(" * @throws "); //$NON-NLS-1$
				this.[i].print(indentoutput).append('\n');
				if (!nodePrinted && this. != null) {
					nodePrinted =  this. == this.[i];
				}
			}
		}
		if (this. != null) {
			for (int i = 0, length = this..lengthi < lengthi++) {
				printIndent(indentoutput).append(" * @see "); //$NON-NLS-1$
				this.[i].print(indentoutput).append('\n');
				if (!nodePrinted && this. != null) {
					nodePrinted =  this. == this.[i];
				}
			}
		}
		if (!nodePrinted && this. != null) {
			printIndent(indentoutput).append(" * "); //$NON-NLS-1$
			this..print(indentoutput).append('\n');
		}
		printIndent(indentoutput).append(" */\n"); //$NON-NLS-1$
		return output;
	}

Resolve completion node if not null and throw exception to let clients know that it has been found.

	public void resolve(ClassScope scope) {
		super.resolve(scope);
	}

Resolve completion node if not null and throw exception to let clients know that it has been found.

	public void resolve(CompilationUnitScope scope) {
	}

Resolve completion node if not null and throw exception to let clients know that it has been found.

	public void resolve(MethodScope scope) {
		super.resolve(scope);
	}
	/*
	 * Look for missing method @param tags
	 */
	private char[][] missingParamTags(Binding paramNameRefBindingMethodScope methScope) {
		// Verify if there's some possible param tag
		int paramTagsSize = this. == null ? 0 : this..length;
		if (md == nullreturn null;
		int argumentsSize = md.arguments == null ? 0 : md.arguments.length;
		if (argumentsSize == 0) return null;
		// Store all method arguments if there's no @param in javadoc
		if (paramTagsSize == 0) {
			char[][] missingParams = new char[argumentsSize][];
			for (int i = 0; i < argumentsSizei++) {
				missingParams[i] = md.arguments[i].;
			}
			return missingParams;
		}
		// Look for missing arguments
		char[][] missingParams = new char[argumentsSize][];
		int size = 0;
		for (int i = 0; i < argumentsSizei++) {
			Argument arg = md.arguments[i];
			boolean found = false;
			int paramNameRefCount = 0;
			for (int j = 0; j < paramTagsSize && !foundj++) {
				if (arg.binding == param.binding) {
					if (param.binding == paramNameRefBinding) { // do not count first occurence of param name reference
						paramNameRefCount++;
						found = paramNameRefCount > 1;
else {
						found = true;
					}
				}
			}
			if (!found) {
				missingParams[size++] = arg.name;
			}
		}
		if (size > 0) {
			if (size != argumentsSize) {
				System.arraycopy(missingParams, 0, missingParams = new char[size][], 0, size);
			}
			return missingParams;
		}
		return null;
	}
	/*
	 * Look for missing type parameters @param tags
	 */
	private char[][] missingTypeParameterTags(Binding paramNameRefBindingScope scope) {
		int paramTypeParamLength = this. == null ? 0 : this..length;
		// Verify if there's any type parameter to tag
		TypeParameter[] parameters =  null;
		TypeVariableBinding[] typeVariables = null;
		switch (scope.kind) {
				AbstractMethodDeclaration methodDeclaration = ((MethodScope)scope).referenceMethod();
				if (methodDeclaration == nullreturn null;
				parameters = methodDeclaration.typeParameters();
				typeVariables = methodDeclaration.binding.typeVariables;
				break;
				TypeDeclaration typeDeclaration = ((ClassScopescope).;
				parameters = typeDeclaration.typeParameters;
				typeVariables = typeDeclaration.binding.typeVariables;
				break;
		}
		if (typeVariables == null || typeVariables.length == 0) return null;
		// Store all type parameters if there's no @param in javadoc
		if (parameters != null) {
			int typeParametersLength = parameters.length;
			if (paramTypeParamLength == 0) {
				char[][] missingParams = new char[typeParametersLength][];
				for (int i = 0; i < typeParametersLengthi++) {
					missingParams[i] = parameters[i].;
				}
				return missingParams;
			}
			// Look for missing type parameter
			char[][] missingParams = new char[typeParametersLength][];
			int size = 0;
			for (int i = 0; i < typeParametersLengthi++) {
				TypeParameter parameter = parameters[i];
				boolean found = false;
				int paramNameRefCount = 0;
				for (int j = 0; j < paramTypeParamLength && !foundj++) {
					if (parameter.binding == this.[j].) {
						if (parameter.binding == paramNameRefBinding) { // do not count first occurence of param nmae reference
							paramNameRefCount++;
							found = paramNameRefCount > 1;
else {
							found = true;
						}
					}
				}
				if (!found) {
					missingParams[size++] = parameter.name;
				}
			}
			if (size > 0) {
				if (size != typeParametersLength) {
					System.arraycopy(missingParams, 0, missingParams = new char[size][], 0, size);
				}
				return missingParams;
			}
		}
		return null;
	}
New to GrepCode? Check out our FAQ X