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

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


  private void buildContext(
      ASTNode astNode,
      ASTNode astNodeParent,
      Binding qualifiedBinding,
      Scope scope) {
    CompletionContext context = new CompletionContext();
   
    // build expected types context
    if (this.expectedTypesPtr > -1) {
      int length = this.expectedTypesPtr + 1;
      char[][] expTypes = new char[length][];
      char[][] expKeys = new char[length][];
      for (int i = 0; i < length; i++) {
        expTypes[i] = getSignature(this.expectedTypes[i]);
        expKeys[i] = this.expectedTypes[i].computeUniqueKey();
      }
      context.setExpectedTypesSignatures(expTypes);
      context.setExpectedTypesKeys(expKeys);
    }
   
    context.setOffset(this.actualCompletionPosition + 1 - this.offset);
   
    // Set javadoc info
    if (astNode instanceof CompletionOnJavadoc) {
      this.assistNodeInJavadoc = ((CompletionOnJavadoc)astNode).getCompletionFlags();
      context.setJavadoc(this.assistNodeInJavadoc);
    }
   
    if (!(astNode instanceof CompletionOnJavadoc)) {
      CompletionScanner scanner = (CompletionScanner)this.parser.scanner;
      context.setToken(scanner.completionIdentifier);
      context.setTokenRange(
          scanner.completedIdentifierStart - this.offset,
          scanner.completedIdentifierEnd - this.offset,
          scanner.endOfEmptyToken - this.offset);
    } else if(astNode instanceof CompletionOnJavadocTag) {
      CompletionOnJavadocTag javadocTag = (CompletionOnJavadocTag) astNode;
      context.setToken(CharOperation.concat(new char[]{'@'}, javadocTag.token));
      context.setTokenRange(
          javadocTag.tagSourceStart - this.offset,
          javadocTag.tagSourceEnd - this.offset,
          ((CompletionScanner)this.parser.javadocParser.scanner).endOfEmptyToken - this.offset);
    } else {
      CompletionScanner scanner = (CompletionScanner)this.parser.javadocParser.scanner;
      context.setToken(scanner.completionIdentifier);
      context.setTokenRange(
          scanner.completedIdentifierStart - this.offset,
          scanner.completedIdentifierEnd - this.offset,
          scanner.endOfEmptyToken - this.offset);
    }
   
    if(astNode instanceof CompletionOnStringLiteral) {
      context.setTokenKind(CompletionContext.TOKEN_KIND_STRING_LITERAL);
    } else {
      context.setTokenKind(CompletionContext.TOKEN_KIND_NAME);
    }
   
    if(DEBUG) {
      System.out.println(context.toString());
    }
    this.requestor.acceptContext(context);
  }
View Full Code Here


          }
        }
        if(this.noProposal && this.problem != null) {
          if(!contextAccepted) {
            contextAccepted = true;
            this.requestor.acceptContext(new CompletionContext());
          }
          this.requestor.completionFailure(this.problem);
          if(DEBUG) {
            this.printDebug(this.problem);
          }
        }
      }
    }  catch (IndexOutOfBoundsException e) { // work-around internal failure - 1GEMF6D (added with fix of 99629)
      if(DEBUG) {
        System.out.println("Exception caught by CompletionEngine:"); //$NON-NLS-1$
        e.printStackTrace(System.out);
      }
    } catch (InvalidCursorLocation e) { // may eventually report a usefull error (added to fix 99629)
      if(DEBUG) {
        System.out.println("Exception caught by CompletionEngine:"); //$NON-NLS-1$
        e.printStackTrace(System.out);
      }
    } catch (AbortCompilation e) { // ignore this exception for now since it typically means we cannot find java.lang.Object (added with fix of 99629)
      if(DEBUG) {
        System.out.println("Exception caught by CompletionEngine:"); //$NON-NLS-1$
        e.printStackTrace(System.out);
      }
    } catch (CompletionNodeFound e){ // internal failure - bugs 5618 (added with fix of 99629)
      if(DEBUG) {
        System.out.println("Exception caught by CompletionEngine:"); //$NON-NLS-1$
        e.printStackTrace(System.out);
      }
    } catch(JavaModelException e) {
      // Do nothing
    }
    if(!contextAccepted) {
      contextAccepted = true;
      this.requestor.acceptContext(new CompletionContext());
    }
    if(this.requestor != null){
      this.requestor.endReporting();
    }
  }
View Full Code Here

      }
     
      if(this.noProposal && this.problem != null) {
        if(!contextAccepted) {
          contextAccepted = true;
          CompletionContext context = new CompletionContext();
          context.setOffset(completionPosition - this.offset);
          context.setTokenKind(CompletionContext.TOKEN_KIND_UNKNOWN);
          this.requestor.acceptContext(context);
        }
        this.requestor.completionFailure(this.problem);
        if(DEBUG) {
          this.printDebug(this.problem);
        }
      }
      /* Ignore package, import, class & interface keywords for now...
          if (!completionNodeFound) {
            if (parsedUnit == null || parsedUnit.types == null) {
              // this is not good enough... can still be trying to define a second type
              CompletionScanner scanner = (CompletionScanner) this.parser.scanner;
              setSourceRange(scanner.completedIdentifierStart, scanner.completedIdentifierEnd);
              findKeywords(scanner.completionIdentifier, mainDeclarations, null);
            }
            // currently have no way to know if extends/implements are possible keywords
          }
      */
    } catch (IndexOutOfBoundsException e) { // work-around internal failure - 1GEMF6D
      if(DEBUG) {
        System.out.println("Exception caught by CompletionEngine:"); //$NON-NLS-1$
        e.printStackTrace(System.out);
      }
    } catch (InvalidCursorLocation e) { // may eventually report a usefull error
      if(DEBUG) {
        System.out.println("Exception caught by CompletionEngine:"); //$NON-NLS-1$
        e.printStackTrace(System.out);
      }
    } catch (AbortCompilation e) { // ignore this exception for now since it typically means we cannot find java.lang.Object
      if(DEBUG) {
        System.out.println("Exception caught by CompletionEngine:"); //$NON-NLS-1$
        e.printStackTrace(System.out);
      }
    } catch (CompletionNodeFound e){ // internal failure - bugs 5618
      if(DEBUG) {
        System.out.println("Exception caught by CompletionEngine:"); //$NON-NLS-1$
        e.printStackTrace(System.out);
      }
    } finally {
      reset();
      if(!contextAccepted) {
        contextAccepted = true;
        CompletionContext context = new CompletionContext();
        context.setTokenKind(CompletionContext.TOKEN_KIND_UNKNOWN);
        context.setOffset(completionPosition - this.offset);
        this.requestor.acceptContext(context);
      }
      this.requestor.endReporting();
    }
  }
View Full Code Here

TOP

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

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.