Examples of IBinaryType


Examples of org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryType

  NameEnvironmentAnswer result = this.env.findType(compoundTypeName);
  if (result != null) {
    return result;
  }
  if (CharOperation.equals(compoundTypeName, ROOT_COMPOUND_NAME)) {
    IBinaryType binary = this.context.getRootCodeSnippetBinary();
    if (binary == null) {
      return null;
    } else {
      return new NameEnvironmentAnswer(binary, null /*no access restriction*/);
    }
 
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryType

  };
 
  CompletionEngine engine = new CompletionEngine(environment, mapper.getCompletionRequestor(requestor), options, project);
 
  if (this.installedVars != null) {
    IBinaryType binaryType = this.getRootCodeSnippetBinary();
    if (binaryType != null) {
      engine.lookupEnvironment.cacheBinaryType(binaryType, null /*no access restriction*/);
    }
   
    ClassFile[] classFiles = installedVars.classFiles;
    for (int i = 0; i < classFiles.length; i++) {
      ClassFile classFile = classFiles[i];
      IBinaryType binary = null;
      try {
        binary = new ClassFileReader(classFile.getBytes(), null);
      } catch (ClassFormatException e) {
        e.printStackTrace(); // Should never happen since we compiled this type
      }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryType

    this.packageNames.clear();// = Collections.EMPTY_SET;
  }

  private NameEnvironmentAnswer findType(String name) {
    // pr133532 - ask the state for the type first
    IBinaryType seenOnPreviousBuild = state.checkPreviousBuild(name);
    if (seenOnPreviousBuild != null) {
      return new NameEnvironmentAnswer(seenOnPreviousBuild, null);
    }
    if (this.inflatedClassFilesCache.containsKey(name)) {
      return (NameEnvironmentAnswer) this.inflatedClassFilesCache.get(name);
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryType

    char[][] cname = CharOperation.splitOn('.',name.toCharArray());
    NameEnvironmentAnswer answer = nameEnv.findType(cname);
    if (answer == null || !answer.isBinaryType()) {
      return null;
    } else {
      IBinaryType binType = answer.getBinaryType();
      // XXX - but better than the alternative hacks
      if (binType instanceof ClassFileReader) {
        ClassFileReader cfr = (ClassFileReader) binType;
        cf = new ClassFileReaderBackedClassFile(cfr);
      } else {
        throw new IllegalArgumentException(
            "I'm only geared up to handle ClassFileReaders, and you gave me a " +
            binType.getClass().getName());
      }
      return cf;
    }
  }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryType

              if (sourceString == null) {
                throw new IllegalStateException();
              }
              PackageFragment packageFragment = (PackageFragment) this.typeRoot.getParent();
              BinaryType type = (BinaryType) this.typeRoot.findPrimaryType();
              IBinaryType binaryType = (IBinaryType) type.getElementInfo();
              // file name is used to recreate the Java element, so it has to be the toplevel .class file name
              char[] fileName = binaryType.getFileName();
              int firstDollar = CharOperation.indexOf('$', fileName);
              if (firstDollar != -1) {
                char[] suffix = SuffixConstants.SUFFIX_class;
                int suffixLength = suffix.length;
                char[] newFileName = new char[firstDollar + suffixLength];
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryType

  if (mapper != null) {
    char[][] paramNames = mapper.getMethodParameterNames(this);
   
    // map source and try to find parameter names
    if(paramNames == null) {
      IBinaryType info = (IBinaryType) ((BinaryType) getDeclaringType()).getElementInfo();
      char[] source = mapper.findSource(type, info);
      if (source != null){
        mapper.mapSource(type, source, info);
      }
      paramNames = mapper.getMethodParameterNames(this);
    }
   
    // if parameter names exist, convert parameter names to String array
    if(paramNames != null) {
      this.parameterNames = new String[paramNames.length];
      for (int i = 0; i < paramNames.length; i++) {
        this.parameterNames[i] = new String(paramNames[i]);
      }
      return this.parameterNames;
    }
  }
 
  // try to see if we can retrieve the names from the attached javadoc
  IBinaryMethod info = (IBinaryMethod) getElementInfo();
  final int paramCount = Signature.getParameterCount(new String(info.getMethodDescriptor()));
  if (paramCount != 0) {
    // don't try to look for javadoc for synthetic methods
    int modifiers = this.getFlags();
    if ((modifiers & ClassFileConstants.AccSynthetic) != 0) {
      return this.parameterNames = getRawParameterNames(paramCount);
    }
    String javadocContents = null;
    IType declaringType = this.getDeclaringType();
    PerProjectInfo projectInfo = JavaModelManager.getJavaModelManager().getPerProjectInfoCheckExistence(this.getJavaProject().getProject());
    synchronized (projectInfo.javadocCache) {
      javadocContents = (String) projectInfo.javadocCache.get(declaringType);
      if (javadocContents == null) {
        projectInfo.javadocCache.put(declaringType, BinaryType.EMPTY_JAVADOC);
      }
    }
    if (javadocContents == null) {
      long timeOut = 50; // default value
      try {
        String option = this.getJavaProject().getOption(JavaCore.TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC, true);
        if (option != null) {
          timeOut = Long.parseLong(option);
        }
      } catch(NumberFormatException e) {
        // ignore
      }
      if (timeOut == 0) {
        // don't try to fetch the values
        return this.parameterNames = getRawParameterNames(paramCount);
      }
      final class ParametersNameCollector {
        String javadoc;
        public void setJavadoc(String s) {
          this.javadoc = s;
        }
        public String getJavadoc() {
          return this.javadoc;
        }
      }
      /*
       * The declaring type is not in the cache yet. The thread wil retrieve the javadoc contents
       */
      final ParametersNameCollector nameCollector = new ParametersNameCollector();
      Thread collect = new Thread() {
        public void run() {
          try {
            // this call has a side-effect on the per project info cache
            nameCollector.setJavadoc(BinaryMethod.this.getAttachedJavadoc(null));
          } catch (JavaModelException e) {
            // ignore
          }
          synchronized(nameCollector) {
            nameCollector.notify();
          }
        }
      };
      collect.start();
      synchronized(nameCollector) {
        try {
          nameCollector.wait(timeOut);
        } catch (InterruptedException e) {
          // ignore
        }
      }
      javadocContents = nameCollector.getJavadoc();
    } else if (javadocContents != BinaryType.EMPTY_JAVADOC){
      // need to extract the part relative to the binary method since javadoc contains the javadoc for the declaring type
      try {
        javadocContents = extractJavadoc(declaringType, javadocContents);
      } catch(JavaModelException e) {
        // ignore
      }
    } else {
      // let's see if we can retrieve them from the debug infos
      char[][] argumentNames = info.getArgumentNames();
      if (argumentNames != null && argumentNames.length == paramCount) {
        String[] names = new String[paramCount];
        for (int i = 0; i < paramCount; i++) {
          names[i] = new String(argumentNames[i]);
        }
        return this.parameterNames = names;
      }
      return getRawParameterNames(paramCount);
    }
    if (javadocContents != null && javadocContents != BinaryType.EMPTY_JAVADOC) {
      final int indexOfOpenParen = javadocContents.indexOf('(');
      if (indexOfOpenParen != -1) {
        final int indexOfClosingParen = javadocContents.indexOf(')', indexOfOpenParen);
        if (indexOfClosingParen != -1) {
          final char[] paramsSource =
            CharOperation.replace(
              javadocContents.substring(indexOfOpenParen + 1, indexOfClosingParen).toCharArray(),
              "&nbsp;".toCharArray(), //$NON-NLS-1$
              new char[] {' '});
          final char[][] params = splitParameters(paramsSource, paramCount);
          final int paramsLength = params.length;
          this.parameterNames = new String[paramsLength];
          for (int i = 0; i < paramsLength; i++) {
            final char[] param = params[i];
            int indexOfSpace = CharOperation.lastIndexOf(' ', param);
            if (indexOfSpace != -1) {
              this.parameterNames[i] = String.valueOf(param, indexOfSpace + 1, param.length - indexOfSpace -1);
            } else {
              this.parameterNames[i] = "arg" + i; //$NON-NLS-1$
            }
          }
          return this.parameterNames;
        }
      }
    }
    // let's see if we can retrieve them from the debug infos
    char[][] argumentNames = info.getArgumentNames();
    if (argumentNames != null && argumentNames.length == paramCount) {
      String[] names = new String[paramCount];
      for (int i = 0; i < paramCount; i++) {
        names[i] = new String(argumentNames[i]);
      }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryType

}
/*
* @see IMember#getFlags()
*/
public int getFlags() throws JavaModelException {
  IBinaryType info = (IBinaryType) getElementInfo();
  return info.getModifiers();
}
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryType

/**
* @see IType#getSuperclassTypeSignature()
* @since 3.0
*/
public String getSuperclassTypeSignature() throws JavaModelException {
  IBinaryType info = (IBinaryType) getElementInfo();
  char[] genericSignature = info.getGenericSignature();
  if (genericSignature != null) {
    int signatureLength = genericSignature.length;
    // skip type parameters
    int index = 0;
    if (genericSignature[0] == '<') {
      int count = 1;
      while (count > 0 && ++index < signatureLength) {
        switch (genericSignature[index]) {
          case '<':
            count++;
            break;
          case '>':
            count--;
            break;
        }
      }
      index++;
    }
    int start = index;
    index = Util.scanClassTypeSignature(genericSignature, start) + 1;
    char[] superclassSig = CharOperation.subarray(genericSignature, start, index);
    return new String(ClassFile.translatedName(superclassSig));
  } else {
    char[] superclassName = info.getSuperclassName();
    if (superclassName == null) {
      return null;
    }
    return new String(Signature.createTypeSignature(ClassFile.translatedName(superclassName), true));
  }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryType

/*
* @see IType#getSuperclassName()
*/
public String getSuperclassName() throws JavaModelException {
  IBinaryType info = (IBinaryType) getElementInfo();
  char[] superclassName = info.getSuperclassName();
  if (superclassName == null) {
    return null;
  }
  return new String(ClassFile.translatedName(superclassName));
}
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryType

}
/*
* @see IType#getSuperInterfaceNames()
*/
public String[] getSuperInterfaceNames() throws JavaModelException {
  IBinaryType info = (IBinaryType) getElementInfo();
  char[][] names= info.getInterfaceNames();
  int length;
  if (names == null || (length = names.length) == 0) {
    return CharOperation.NO_STRINGS;
  }
  names= ClassFile.translatedNames(names);
View Full Code Here
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.