Java 类org.eclipse.jdt.core.eval.IEvaluationContext 实例源码

项目:gwt-eclipse-plugin    文件:JavaElExpressionProposalComputer.java   
public void computeProposals(List<ICompletionProposal> proposals)
    throws UiBinderException {
  IEvaluationContext evalContext = createEvaluationContext();

  try {
    // Get proposals for instance methods and static methods by treating the
    // Java type as an instance.
    // Since the type does not necessarily have to have a zero-arg
    // constructor, we use a local variable in the completion request below
    JavaElExpressionCompletionRequestor requestor = new JavaElExpressionCompletionRequestor(
        CompletionProposal.METHOD_REF);
    String snippet = javaType.getFullyQualifiedName('.') + " tmpVar; tmpVar."
        + getEnteredText();
    evalContext.codeComplete(snippet, snippet.length(), requestor);
    proposals.addAll(requestor.getProposals());

  } catch (JavaModelException e) {
    throw new UiBinderException(e);
  }
}
项目:gwt-eclipse-plugin    文件:CodeCompleteProposalComputer.java   
public void computeProposals(List<ICompletionProposal> proposals)
    throws UiBinderException {
  try {
    IEvaluationContext evalContext = createEvaluationContext();

    // for <ui:import field='____'> autocomplete
    if (packageName != null) {
      evalContext.setPackageName(packageName);
    }

    ProposalGeneratingCompletionRequestor requestor = new ProposalGeneratingCompletionRequestor(
        getReplaceOffset(), getReplaceLength(), allowedCompletionTypes,
        getJavaProject(), forceFullyQualifiedFieldNames);

    if (getEnteredText().trim().length() == 0) {
      completeCodeUsingAlphabet(evalContext, requestor);
    } else {
      evalContext.codeComplete(getEnteredText(), getEnteredText().length(),
          requestor);
    }
    proposals.addAll(requestor.getProposals());
  } catch (JavaModelException e) {
    throw new UiBinderException(e);
  }
}
项目:gwt-eclipse-plugin    文件:JsniCompletionProcessor.java   
private IJavaCompletionProposal[] computePackageAndTypeProposals(String js,
    int lineStartOffset, int cursorOffset) throws JavaModelException {
  Matcher matcher = PACKAGE_OR_TYPE_REF_START.matcher(js);
  if (!matcher.find()) {
    // Bail if we're not inside a JSNI Java package/type reference
    return null;
  }

  // Extract from the match the (maybe partial) package/type reference
  int refOffset = matcher.start(1) + lineStartOffset;
  int refLength = cursorOffset - refOffset;
  String partialRef = matcher.group(1);

  CompletionProposalCollector requestor = JsniCompletionProposalCollector.createPackageAndTypeProposalCollector(
      cu, refOffset, refLength);
  IEvaluationContext evalContext = createEvaluationContext();
  evalContext.codeComplete(partialRef, partialRef.length(), requestor);
  return requestor.getJavaCompletionProposals();
}
项目:gwt-eclipse-plugin    文件:WidgetProposalComputer.java   
public void computeProposals(List<ICompletionProposal> proposals)
    throws UiBinderException {

  if (!isWidgetAllowed()) {
    return;
  }

  IEvaluationContext evalContext = createEvaluationContext();
  String packageName = null;
  String prefix = XmlUtilities.getPrefix(enteredText);
  if (prefix != null) {
    packageName = packageManager.getPackageName(prefix);
    if (packageName == null) {
      // The user has specified a namespace prefix but there is not a matching
      // package, so no widgets here
      return;
    }
  }

  ProposalGeneratingCompletionRequestor requestor = new WidgetCompletionRequestor(
      packageName);

  String unprefixedEnteredText = XmlUtilities.getUnprefixed(enteredText);

  try {
    if (unprefixedEnteredText.trim().length() > 0) {
      evalContext.codeComplete(enteredText, enteredText.length(), requestor);
    } else {
      // Offer all possible types available to the project as
      // completions. See
      // http://code.google.com/p/google-plugin-for-eclipse/issues/detail?id=11
      CodeCompleteProposalComputer.completeCodeUsingAlphabet(evalContext,
          requestor);
    }
    proposals.addAll(requestor.getProposals());
  } catch (JavaModelException e) {
    throw new UiBinderException(e);
  }
}
项目:gwt-eclipse-plugin    文件:CodeCompleteProposalComputer.java   
public static void completeCodeUsingAlphabet(IEvaluationContext evalContext,
    ProposalGeneratingCompletionRequestor requestor)
    throws JavaModelException {
  for (char letter = 'a'; letter <= 'z'; letter++) {
    evalContext.codeComplete(String.valueOf(letter), 1, requestor);
    if (requestor.getProposals().size() > 0) {
      /*
       * Once we've hit a letter that returns at least one valid proposal,
       * bail out.
       */
      return;
    }
  }
}
项目:gwt-eclipse-plugin    文件:JsniCompletionProcessor.java   
private IEvaluationContext createEvaluationContext()
    throws JavaModelException {
  IJavaProject project = cu.getJavaProject();
  IEvaluationContext evalContext = project.newEvaluationContext();
  String pckgName = cu.getPackageDeclarations()[0].getElementName();
  // Scope evaluation to the containing package
  evalContext.setPackageName(pckgName);
  return evalContext;
}
项目:che    文件:JavaProject.java   
@Override
public IEvaluationContext newEvaluationContext() {
  throw new UnsupportedOperationException();
}
项目:gwt-eclipse-plugin    文件:AbstractJavaProposalComputer.java   
public IEvaluationContext createEvaluationContext() {
  return javaProject.newEvaluationContext();
}
项目:gwt-eclipse-plugin    文件:JavaElExpressionProposalComputer.java   
@Override
public IEvaluationContext createEvaluationContext() {
  IEvaluationContext evalContext = super.createEvaluationContext();
  evalContext.setPackageName(javaType.getPackageFragment().getElementName());
  return evalContext;
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaProject.java   
/**
 * @see IJavaProject#newEvaluationContext()
 */
public IEvaluationContext newEvaluationContext() {
    EvaluationContext context = new EvaluationContext();
    context.setLineSeparator(Util.getLineSeparator(null/*no existing source*/, this));
    return new EvaluationContextWrapper(context, this);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaProject.java   
/**
 * @see IJavaProject#newEvaluationContext()
 */
public IEvaluationContext newEvaluationContext() {
    EvaluationContext context = new EvaluationContext();
    context.setLineSeparator(Util.getLineSeparator(null/*no existing source*/, this));
    return new EvaluationContextWrapper(context, this);
}
项目:Eclipse-Postfix-Code-Completion    文件:IJavaProject.java   
/**
 * Creates a new evaluation context.
 * @return a new evaluation context.
 */
IEvaluationContext newEvaluationContext();
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:IJavaProject.java   
/**
 * Creates a new evaluation context.
 * @return a new evaluation context.
 */
IEvaluationContext newEvaluationContext();