Package org.aspectj.org.eclipse.jdt.internal.compiler.ast

Source Code of org.aspectj.org.eclipse.jdt.internal.compiler.ast.JavadocSingleTypeReference

/*******************************************************************************
* Copyright (c) 2000, 2007 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.aspectj.org.eclipse.jdt.internal.compiler.ast;

import org.aspectj.org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.aspectj.org.eclipse.jdt.internal.compiler.impl.Constant;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Scope;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding;


public class JavadocSingleTypeReference extends SingleTypeReference {
 
  public int tagSourceStart, tagSourceEnd;
  public PackageBinding packageBinding;

  public JavadocSingleTypeReference(char[] source, long pos, int tagStart, int tagEnd) {
    super(source, pos);
    this.tagSourceStart = tagStart;
    this.tagSourceEnd = tagEnd;
    this.bits |= ASTNode.InsideJavadoc;
  }

  protected void reportInvalidType(Scope scope) {
    scope.problemReporter().javadocInvalidType(this, this.resolvedType, scope.getDeclarationModifiers());
  }
  protected void reportDeprecatedType(TypeBinding type, Scope scope) {
    scope.problemReporter().javadocDeprecatedType(type, this, scope.getDeclarationModifiers());
  }

  /* (non-Javadoc)
   * Redefine to capture javadoc specific signatures
   * @see org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode#traverse(org.aspectj.org.eclipse.jdt.internal.compiler.ASTVisitor, org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BlockScope)
   */
  public void traverse(ASTVisitor visitor, BlockScope scope) {
    visitor.visit(this, scope);
    visitor.endVisit(this, scope);
  }
 
  public void traverse(ASTVisitor visitor, ClassScope scope) {
    visitor.visit(this, scope);
    visitor.endVisit(this, scope);
  }

  /*
   * We need to modify resolving behavior to handle package references
   */
  TypeBinding internalResolveType(Scope scope) {
    // handle the error here
    this.constant = Constant.NotAConstant;
    if (this.resolvedType != null)// is a shared type reference which was already resolved
      return this.resolvedType.isValidBinding() ? this.resolvedType : null; // already reported error

    this.resolvedType = getTypeBinding(scope);
    if (!this.resolvedType.isValidBinding()) {
      char[][] tokens = { this.token };
      Binding binding = scope.getTypeOrPackage(tokens);
      if (binding instanceof PackageBinding) {
        this.packageBinding = (PackageBinding) binding;
      } else {
        if (this.resolvedType.problemId() == ProblemReasons.NonStaticReferenceInStaticContext) {
          ReferenceBinding closestMatch = ((ProblemReferenceBinding)this.resolvedType).closestMatch();
          if (closestMatch != null && closestMatch.isTypeVariable()) {
            this.resolvedType = closestMatch; // ignore problem as we want report specific javadoc one instead
            return this.resolvedType;
          }
        }
        reportInvalidType(scope);
      }
      return null;
    }
    if (isTypeUseDeprecated(this.resolvedType, scope))
      reportDeprecatedType(this.resolvedType, scope);
    if (this.resolvedType instanceof ParameterizedTypeBinding) {
      this.resolvedType = ((ParameterizedTypeBinding)this.resolvedType).genericType();
    }
    return this.resolvedType;
  }

  /* (non-Javadoc)
   * @see org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression#resolveType(org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BlockScope)
   * We need to override to handle package references
   */
  public TypeBinding resolveType(BlockScope blockScope, boolean checkBounds) {
    return internalResolveType(blockScope);
  }

  public TypeBinding resolveType(ClassScope classScope) {
    return internalResolveType(classScope);
  }
}
TOP

Related Classes of org.aspectj.org.eclipse.jdt.internal.compiler.ast.JavadocSingleTypeReference

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.