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

Examples of org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration


        assertThat(methodNode.getFullyQualifiedName(), is("org.foo.Clazz.method(String,int)"));
    }

    private void createStructureTree() {
        JavaCompilation compilation = CompilationUtils.compileSource(fSnippet);
        CompilationUnitDeclaration cu = compilation.getCompilationUnit();
        fRoot = new JavaStructureNode(Type.CU, null, null, cu);
        cu.traverse(new JavaStructureTreeBuilder(fRoot), (CompilationUnitScope) null);
    }
View Full Code Here


  public void testRecordError() {
    String fileName = "TestCompilationUnit.java";
    String errorMessage = "Unit has errors";
    CompilationResult compilationResult = new CompilationResult(
        fileName.toCharArray(), 0, 0, 0);
    CompilationUnitDeclaration cud = new CompilationUnitDeclaration(null,
        compilationResult, 0);

    HelpInfo info = new HelpInfo() {
    };
View Full Code Here

   * find all of these locations except for the one used in an annotation.
   */
  public void testFindAllBinaryTypeReferenceSites() {
    CompilationResult compilationResult = new CompilationResult(
        "TestCompilationUnit.java".toCharArray(), 0, 0, 0);
    CompilationUnitDeclaration cud = new CompilationUnitDeclaration(null,
        compilationResult, 1);
    LookupEnvironment lookupEnvironment = createMockLookupEnvironment();
    cud.scope = new CompilationUnitScope(cud, lookupEnvironment);

    TypeDeclaration typeDeclaration = new TypeDeclaration(compilationResult);
View Full Code Here

  public static void validateCompilationUnits(Set<CompilationUnit> units,
      Set<String> validBinaryTypeNames) {
    for (CompilationUnit unit : units) {
      if (unit.getState() == State.COMPILED) {
        CompilationUnitDeclaration jdtCud = unit.getJdtCud();
        JSORestrictionsChecker.check(jdtCud);
        JsniChecker.check(jdtCud);
        BinaryTypeReferenceRestrictionsChecker.check(jdtCud,
            validBinaryTypeNames);
      }
View Full Code Here

    CodeSnippetParsingUtil parsingUtil = new CodeSnippetParsingUtil(true);
    CompilerOptions options = new CompilerOptions();
    options.complianceLevel = ClassFileConstants.JDK1_6;
    options.originalSourceLevel = ClassFileConstants.JDK1_6;
    options.sourceLevel = ClassFileConstants.JDK1_6;
    CompilationUnitDeclaration unit = parsingUtil.parseCompilationUnit(
        javaSource.toString().toCharArray(), options.getMap(), true);
    if (unit.compilationResult().hasProblems()) {
      return null;
    }
    return unit;
  }
View Full Code Here

   * @return array of argument names or null if no source is available
   */
  public synchronized String[] getArguments(JAbstractMethod method) {
    JClassType type = method.getEnclosingType();
    JClassType topType = getTopmostType(type);
    CompilationUnitDeclaration cud = getCudForTopLevelType(topType);
    if (cud == null) {
      return null;
    }
    TypeDeclaration jdtType = findType(cud, type.getQualifiedBinaryName());
    if (jdtType == null) {
View Full Code Here

   * @param topType top-level JClassType
   * @return CUD instance or null if no source found
   */
  private synchronized CompilationUnitDeclaration getCudForTopLevelType(
      JClassType topType) {
    CompilationUnitDeclaration cud = null;
    if (cudCache.containsKey(topType)) {
      SoftReference<CompilationUnitDeclaration> cudRef = cudCache.get(topType);
      if (cudRef != null) {
        cud = cudRef.get();
      }
View Full Code Here

        CompilationResult compilationResult) {
      // Never dietParse(), otherwise GwtIncompatible annotations in anonymoous inner classes
      // would be ignored.
      boolean saveDiet = this.diet;
      this.diet = false;
      CompilationUnitDeclaration decl = super.parse(sourceUnit, compilationResult);
      this.diet = saveDiet;
      if (removeGwtIncompatible) {
        // Remove @GwtIncompatible classes and members.
        // It is safe to remove @GwtIncompatible types, fields and methods on incomplete ASTs due
        // to parsing errors.
        GwtIncompatiblePreprocessor.preproccess(decl);
      }
      if (decl.imports != null) {
        originalImportsByCud.putAll(decl, Arrays.asList(decl.imports));
      }
      if (decl.hasErrors()) {
        // The unit has parsing errors; its JDT AST might not be complete. In this case do not
        // remove unused imports as it is not safe to do so. UnusedImportsRemover would remove
        // imports for types only referred from parts of the AST that was not constructed.
        // Later the error reporting logic would complain about missing types for these references
        // potentially burying the real error among many spurious errors.
View Full Code Here

  DefaultBindingResolver(LookupEnvironment lookupEnvironment, WorkingCopyOwner workingCopyOwner, BindingTables bindingTables, boolean isRecoveringBindings, boolean fromJavaProject) {
    this.newAstToOldAst = new HashMap();
    this.astNodesToBlockScope = new HashMap();
    this.bindingsToAstNodes = new HashMap();
    this.bindingTables = bindingTables;
    this.scope = new CompilationUnitScope(new CompilationUnitDeclaration(null, null, -1), lookupEnvironment);
    this.workingCopyOwner = workingCopyOwner;
    this.isRecoveringBindings = isRecoveringBindings;
    this.fromJavaProject = fromJavaProject;
  }
View Full Code Here

            return null;
          }
        }
      }
    } else if (node instanceof CompilationUnitDeclaration) {
      CompilationUnitDeclaration compilationUnitDeclaration = (CompilationUnitDeclaration) node;
      org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] types = compilationUnitDeclaration.types;
      if (types == null || types.length == 0) {
        return null;
      }
      org.eclipse.jdt.internal.compiler.ast.TypeDeclaration type = types[0];
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration

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.