Package org.aspectj.org.eclipse.jdt.core

Examples of org.aspectj.org.eclipse.jdt.core.IType


    int length = paramTypeNames.length;
   
    char[] tName = CharOperation.concat(declaringTypePackageName,declaringTypeName,'.');
    Object cachedType = this.completionEngine.typeCache.get(tName);
   
    IType type = null;
    if(cachedType != null) {
      if(cachedType != NO_ATTACHED_SOURCE && cachedType instanceof BinaryType) {
        type = (BinaryType)cachedType;
      }
    } else {
      // TODO (david) shouldn't it be NameLookup.ACCEPT_ALL ?
      NameLookup.Answer answer = this.nameLookup.findType(new String(tName),
        false,
        NameLookup.ACCEPT_CLASSES & NameLookup.ACCEPT_INTERFACES,
        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.completionEngine.typeCache.put(tName, type);
      } else {
        type = null;
      }
    }
   
    if(type != null) {
      String[] args = new String[length];
      for(int i = 0;  i< length ; i++){
        args[i] = new String(paramTypeNames[i]);
      }
      IMethod method = type.getMethod(new String(selector),args);
      try{
        parameterNames = new char[length][];
        String[] params = method.getParameterNames();
        for(int i = 0;  i< length ; i++){
          parameterNames[i] = params[i].toCharArray();
View Full Code Here


* Returns the source used to generate this node.
*/
protected String generateSyntaxIncorrectAST() {
  //create some dummy source to generate an ast node
  StringBuffer buff = new StringBuffer();
  IType type = getType();
  String lineSeparator = org.aspectj.org.eclipse.jdt.internal.core.util.Util.getLineSeparator(this.source, type == null ? null : type.getJavaProject());
  buff.append(lineSeparator + " public class A {" + lineSeparator); //$NON-NLS-1$
  buff.append(this.source);
  buff.append(lineSeparator).append('}');
  ASTParser parser = ASTParser.newParser(AST.JLS3);
  parser.setSource(buff.toString().toCharArray());
View Full Code Here

      progressMonitor);
    if (answer == null) {
      // try to find enclosing type
      int lastDot = fullyQualifiedName.lastIndexOf('.');
      if (lastDot == -1) return null;
      IType type = findType(fullyQualifiedName.substring(0, lastDot), lookup, considerSecondaryTypes, progressMonitor);
      if (type != null) {
        type = type.getType(fullyQualifiedName.substring(lastDot+1));
        if (!type.exists()) {
          return null;
        }
      }
      return type;
    }
View Full Code Here

* By default the new field is positioned after the last existing field
* declaration, or as the first member in the type if there are no
* field declarations.
*/
protected void initializeDefaultPosition() {
  IType parentElement = getType();
  try {
    IField[] fields = parentElement.getFields();
    if (fields != null && fields.length > 0) {
      final IField lastField = fields[fields.length - 1];
      if (parentElement.isEnum()) {
        IField field = lastField;
        if (!field.isEnumConstant()) {
          createAfter(lastField);
        }
      } else {
        createAfter(lastField);
      }
    } else {
      IJavaElement[] elements = parentElement.getChildren();
      if (elements != null && elements.length > 0) {
        createBefore(elements[0]);
      }
    }
  } catch (JavaModelException e) {
View Full Code Here

/**
* @see CreateTypeMemberOperation#verifyNameCollision
*/
protected IJavaModelStatus verifyNameCollision() {
  if (this.createdNode != null) {
    IType type= getType();
    String fieldName = getASTNodeName();
    if (type.getField(fieldName).exists()) {
      return new JavaModelStatus(
        IJavaModelStatusConstants.NAME_COLLISION,
        Messages.bind(Messages.status_nameCollision, fieldName));
    }
  }
View Full Code Here

          case IJavaElement.CLASS_FILE :
          case IJavaElement.COMPILATION_UNIT :
            openables.add(root);
            break;
          case IJavaElement.TYPE :
            IType type = (IType)root;
            if (type.isBinary()) {
              openables.add(type.getClassFile());
            } else {
              openables.add(type.getCompilationUnit());
            }
            break;
          default :
            break;
        }
View Full Code Here

* By default the new initializer is positioned after the last existing initializer
* declaration, or as the first member in the type if there are no
* initializers.
*/
protected void initializeDefaultPosition() {
  IType parentElement = getType();
  try {
    IJavaElement[] elements = parentElement.getInitializers();
    if (elements != null && elements.length > 0) {
      this.numberOfInitializers = elements.length;
      createAfter(elements[elements.length - 1]);
    } else {
      elements = parentElement.getChildren();
      if (elements != null && elements.length > 0) {
        createBefore(elements[0]);
      }
    }
  } catch (JavaModelException e) {
View Full Code Here

      break;
    default:
      acceptFlags = NameLookup.ACCEPT_CLASSES;
      break;
  }
  IType type = null;
  if(isDeclaration) {
    type = resolveTypeByLocation(packageName, typeName, acceptFlags, start, end);
  } else {
    type = resolveType(packageName, typeName, acceptFlags);
    if(type != null ) {
      String key = uniqueKey == null ? type.getKey() : new String(uniqueKey);
      if(type.isBinary()) {
        ResolvedBinaryType resolvedType = new ResolvedBinaryType((JavaElement)type.getParent(), type.getElementName(), key);
        resolvedType.occurrenceCount = type.getOccurrenceCount();
        type = resolvedType;
      } else {
        ResolvedSourceType resolvedType = new ResolvedSourceType((JavaElement)type.getParent(), type.getElementName(), key);
        resolvedType.occurrenceCount = type.getOccurrenceCount();
        type = resolvedType;
      }
    }
  }

  if (type != null) {
    addElement(type);
    if(SelectionEngine.DEBUG){
      System.out.print("SELECTION - accept type("); //$NON-NLS-1$
      System.out.print(type.toString());
      System.out.println(")"); //$NON-NLS-1$
    }
  }
}
View Full Code Here

/**
* Resolve the field.
*/
public void acceptField(char[] declaringTypePackageName, char[] declaringTypeName, char[] name, boolean isDeclaration, char[] uniqueKey, int start, int end) {
  if(isDeclaration) {
    IType type= resolveTypeByLocation(declaringTypePackageName, declaringTypeName,
        NameLookup.ACCEPT_ALL,
        start, end);
    if(type != null) {
      try {
        IField[] fields = type.getFields();
        for (int i = 0; i < fields.length; i++) {
          IField field = fields[i];
          ISourceRange range = field.getNameRange();
          if(range.getOffset() <= start
              && range.getOffset() + range.getLength() >= end
              && field.getElementName().equals(new String(name))) {
            addElement(fields[i]);
            if(SelectionEngine.DEBUG){
              System.out.print("SELECTION - accept field("); //$NON-NLS-1$
              System.out.print(field.toString());
              System.out.println(")"); //$NON-NLS-1$
            }
            return; // only one method is possible
          }
        }
      } catch (JavaModelException e) {
        return;
      }
    }
  } else {
    IType type= resolveType(declaringTypePackageName, declaringTypeName, NameLookup.ACCEPT_ALL);
    if (type != null) {
      IField field= type.getField(new String(name));
      if (field.exists()) {
        if (uniqueKey != null) {
          if(field.isBinary()) {
            ResolvedBinaryField resolvedField = new ResolvedBinaryField(
                (JavaElement)field.getParent(),
View Full Code Here

  } else {
    SourceTypeBinding typeBinding = (SourceTypeBinding)fieldBinding.declaringClass;
    res = findLocalElement(typeBinding.sourceStart());
  }
  if (res != null && res.getElementType() == IJavaElement.TYPE) {
    IType type = (IType) res;
    IField field= type.getField(new String(fieldBinding.name));
    if (field.exists()) {
      char[] uniqueKey = fieldBinding.computeUniqueKey();
      if(field.isBinary()) {
        ResolvedBinaryField resolvedField = new ResolvedBinaryField(
            (JavaElement)field.getParent(),
View Full Code Here

TOP

Related Classes of org.aspectj.org.eclipse.jdt.core.IType

Copyright © 2018 www.massapicom. 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.