Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*******************************************************************************
* Copyright (c) 2000, 2014 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
* Stephan Herrmann - Contribution for
* Bug 400874 - [1.8][compiler] Inference infrastructure should evolve to meet JLS8 18.x (Part G of JSR335 spec)
* Bug 429958 - [1.8][null] evaluate new DefaultLocation attribute of @NonNullByDefault
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.parser.JavadocTagConstants;
/**
* Node representing a structured Javadoc comment
*/
public class Javadoc extends ASTNode {
public JavadocSingleNameReference[] paramReferences; // @param
public JavadocSingleTypeReference[] paramTypeParameters; // @param
public TypeReference[] exceptionReferences; // @throws, @exception
public JavadocReturnStatement returnStatement; // @return
public Expression[] seeReferences; // @see
public long[] inheritedPositions = null;
// bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=51600
// Store param references for tag with invalid syntax
public JavadocSingleNameReference[] invalidParameters; // @param
// bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=153399
// Store value tag positions
public long valuePositions = -1;
public Javadoc(int sourceStart, int sourceEnd) {
this.sourceStart = sourceStart;
this.sourceEnd = sourceEnd;
this.bits |= ASTNode.ResolveJavadoc;
}
/**
* Returns whether a type can be seen at a given visibility level or not.
*
* @param visibility Level of visiblity allowed to see references
* @param modifiers modifiers of java element to be seen
* @return true if the type can be seen, false otherwise
*/
boolean canBeSeen(int visibility, int modifiers) {
if (modifiers < 0) return true;
switch (modifiers & ExtraCompilerModifiers.AccVisibilityMASK) {
case ClassFileConstants.AccPublic :
return true;
case ClassFileConstants.AccProtected:
return (visibility != ClassFileConstants.AccPublic);
case ClassFileConstants.AccDefault:
return (visibility == ClassFileConstants.AccDefault || visibility == ClassFileConstants.AccPrivate);
case ClassFileConstants.AccPrivate:
return (visibility == ClassFileConstants.AccPrivate);
}
return true;
}
/*
* Search node with a given staring position in javadoc objects arrays.
*/
public ASTNode getNodeStartingAt(int start) {
int length = 0;
// parameters array
if (this.paramReferences != null) {
length = this.paramReferences.length;
for (int i=0; i\n"); //$NON-NLS-1$
}
}
if (this.returnStatement != null) {
printIndent(indent + 1, output).append(" * @"); //$NON-NLS-1$
this.returnStatement.print(indent, output).append('\n');
}
if (this.exceptionReferences != null) {
for (int i = 0, length = this.exceptionReferences.length; i < length; i++) {
printIndent(indent + 1, output).append(" * @throws "); //$NON-NLS-1$
this.exceptionReferences[i].print(indent, output).append('\n');
}
}
if (this.seeReferences != null) {
for (int i = 0, length = this.seeReferences.length; i < length; i++) {
printIndent(indent + 1, output).append(" * @see "); //$NON-NLS-1$
this.seeReferences[i].print(indent, output).append('\n');
}
}
printIndent(indent, output).append(" */\n"); //$NON-NLS-1$
return output;
}
/*
* Resolve type javadoc
*/
public void resolve(ClassScope scope) {
if ((this.bits & ASTNode.ResolveJavadoc) == 0) {
return;
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=247037, @inheritDoc tag cannot
// be used in the documentation comment for a class or interface.
if (this.inheritedPositions != null) {
int length = this.inheritedPositions.length;
for (int i = 0; i < length; ++i) {
int start = (int) (this.inheritedPositions[i] >>> 32);
int end = (int) this.inheritedPositions[i];
scope.problemReporter().javadocUnexpectedTag(start, end);
}
}
// @param tags
int paramTagsSize = this.paramReferences == null ? 0 : this.paramReferences.length;
for (int i = 0; i < paramTagsSize; i++) {
JavadocSingleNameReference param = this.paramReferences[i];
scope.problemReporter().javadocUnexpectedTag(param.tagSourceStart, param.tagSourceEnd);
}
resolveTypeParameterTags(scope, true);
// @return tags
if (this.returnStatement != null) {
scope.problemReporter().javadocUnexpectedTag(this.returnStatement.sourceStart, this.returnStatement.sourceEnd);
}
// @throws/@exception tags
int throwsTagsLength = this.exceptionReferences == null ? 0 : this.exceptionReferences.length;
for (int i = 0; i < throwsTagsLength; i++) {
TypeReference typeRef = this.exceptionReferences[i];
int start, end;
if (typeRef instanceof JavadocSingleTypeReference) {
JavadocSingleTypeReference singleRef = (JavadocSingleTypeReference) typeRef;
start = singleRef.tagSourceStart;
end = singleRef.tagSourceEnd;
} else if (typeRef instanceof JavadocQualifiedTypeReference) {
JavadocQualifiedTypeReference qualifiedRef = (JavadocQualifiedTypeReference) typeRef;
start = qualifiedRef.tagSourceStart;
end = qualifiedRef.tagSourceEnd;
} else {
start = typeRef.sourceStart;
end = typeRef.sourceEnd;
}
scope.problemReporter().javadocUnexpectedTag(start, end);
}
// @see tags
int seeTagsLength = this.seeReferences == null ? 0 : this.seeReferences.length;
for (int i = 0; i < seeTagsLength; i++) {
resolveReference(this.seeReferences[i], scope);
}
// @value tag
boolean source15 = scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5;
if (!source15 && this.valuePositions != -1) {
scope.problemReporter().javadocUnexpectedTag((int)(this.valuePositions>>>32), (int) this.valuePositions);
}
}
/*
* Resolve compilation unit javadoc
*/
public void resolve(CompilationUnitScope unitScope) {
if ((this.bits & ASTNode.ResolveJavadoc) == 0) {
return;
}
// Do nothing - This is to mimic the SDK's javadoc tool behavior, which neither
// sanity checks nor generates documentation using comments at the CU scope
// (unless the unit happens to be package-info.java - in which case we don't come here.)
}
/*
* Resolve method javadoc
*/
public void resolve(MethodScope methScope) {
if ((this.bits & ASTNode.ResolveJavadoc) == 0) {
return;
}
// get method declaration
AbstractMethodDeclaration methDecl = methScope.referenceMethod();
boolean overriding = methDecl == null /* field declaration */ || methDecl.binding == null /* compiler error */
? false :
!methDecl.binding.isStatic() && ((methDecl.binding.modifiers & (ExtraCompilerModifiers.AccImplementing | ExtraCompilerModifiers.AccOverriding)) != 0);
// @see tags
int seeTagsLength = this.seeReferences == null ? 0 : this.seeReferences.length;
boolean superRef = false;
for (int i = 0; i < seeTagsLength; i++) {
// Resolve reference
resolveReference(this.seeReferences[i], methScope);
// see whether we can have a super reference
if (methDecl != null && !superRef) {
if (!methDecl.isConstructor()) {
if (overriding && this.seeReferences[i] instanceof JavadocMessageSend) {
JavadocMessageSend messageSend = (JavadocMessageSend) this.seeReferences[i];
// if binding is valid then look if we have a reference to an overriden method/constructor
if (messageSend.binding != null && messageSend.binding.isValidBinding() && messageSend.actualReceiverType instanceof ReferenceBinding) {
ReferenceBinding methodReceiverType = (ReferenceBinding) messageSend.actualReceiverType;
TypeBinding superType = methDecl.binding.declaringClass.findSuperTypeOriginatingFrom(methodReceiverType);
if (superType != null && TypeBinding.notEquals(superType.original(), methDecl.binding.declaringClass) && CharOperation.equals(messageSend.selector, methDecl.selector)) {
if (methScope.environment().methodVerifier().doesMethodOverride(methDecl.binding, messageSend.binding.original())) {
superRef = true;
}
}
}
}
} else if (this.seeReferences[i] instanceof JavadocAllocationExpression) {
JavadocAllocationExpression allocationExpr = (JavadocAllocationExpression) this.seeReferences[i];
// if binding is valid then look if we have a reference to an overriden method/constructor
if (allocationExpr.binding != null && allocationExpr.binding.isValidBinding()) {
ReferenceBinding allocType = (ReferenceBinding) allocationExpr.resolvedType.original();
ReferenceBinding superType = (ReferenceBinding) methDecl.binding.declaringClass.findSuperTypeOriginatingFrom(allocType);
if (superType != null && TypeBinding.notEquals(superType.original(), methDecl.binding.declaringClass)) {
MethodBinding superConstructor = methScope.getConstructor(superType, methDecl.binding.parameters, allocationExpr);
if (superConstructor.isValidBinding() && superConstructor.original() == allocationExpr.binding.original()) {
MethodBinding current = methDecl.binding;
// work 'against' better inference in 1.8 (otherwise comparing (G with G