Java 类org.eclipse.jdt.core.CompletionContext 实例源码

项目:che    文件:JavaContentAssistInvocationContext.java   
/**
 * Returns the content assist type history for the expected type.
 *
 * @return the content assist type history for the expected type
 */
private RHSHistory getRHSHistory() {
  if (fRHSHistory == null) {
    CompletionContext context = getCoreContext();
    if (context != null) {
      char[][] expectedTypes = context.getExpectedTypesSignatures();
      if (expectedTypes != null && expectedTypes.length > 0) {
        String expected = SignatureUtil.stripSignatureToFQN(String.valueOf(expectedTypes[0]));
        fRHSHistory = JavaPlugin.getDefault().getContentAssistHistory().getHistory(expected);
      }
    }
    if (fRHSHistory == null)
      fRHSHistory = JavaPlugin.getDefault().getContentAssistHistory().getHistory(null);
  }
  return fRHSHistory;
}
项目:che    文件:JavaContentAssistInvocationContext.java   
/**
 * Returns the expected type if any, <code>null</code> otherwise.
 *
 * <p><strong>Note:</strong> This method may run {@linkplain
 * org.eclipse.jdt.core.ICodeAssist#codeComplete(int, org.eclipse.jdt.core.CompletionRequestor)
 * codeComplete} on the compilation unit.
 *
 * @return the expected type if any, <code>null</code> otherwise
 */
public IType getExpectedType() {
  if (fType == null && getCompilationUnit() != null) {
    CompletionContext context = getCoreContext();
    if (context != null) {
      char[][] expectedTypes = context.getExpectedTypesSignatures();
      if (expectedTypes != null && expectedTypes.length > 0) {
        IJavaProject project = getCompilationUnit().getJavaProject();
        if (project != null) {
          try {
            fType =
                project.findType(
                    SignatureUtil.stripSignatureToFQN(String.valueOf(expectedTypes[0])));
          } catch (JavaModelException x) {
            JavaPlugin.log(x);
          }
        }
      }
    }
  }
  return fType;
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaContentAssistInvocationContext.java   
/**
 * Returns the {@link CompletionContext core completion context} if available, <code>null</code>
 * otherwise.
 * <p>
 * <strong>Note:</strong> This method may run
 * {@linkplain ICodeAssist#codeComplete(int, org.eclipse.jdt.core.CompletionRequestor) codeComplete}
 * on the compilation unit.
 * </p>
 *
 * @return the core completion context if available, <code>null</code> otherwise
 */
public CompletionContext getCoreContext() {
    if (fCollector != null) {
        CompletionContext context= fCollector.getContext();
        if (context != null) {
            if (fCoreContext == null)
                fCoreContext= context;
            return context;
        }
    }

    if (fCoreContext == null)
        computeKeywordsAndContext(); // Retrieve the context ourselves

    return fCoreContext;
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaContentAssistInvocationContext.java   
/**
 * Returns the content assist type history for the expected type.
 *
 * @return the content assist type history for the expected type
 */
private RHSHistory getRHSHistory() {
    if (fRHSHistory == null) {
        CompletionContext context= getCoreContext();
        if (context != null) {
            char[][] expectedTypes= context.getExpectedTypesSignatures();
            if (expectedTypes != null && expectedTypes.length > 0) {
                String expected= SignatureUtil.stripSignatureToFQN(String.valueOf(expectedTypes[0]));
                fRHSHistory= JavaPlugin.getDefault().getContentAssistHistory().getHistory(expected);
            }
        }
        if (fRHSHistory == null)
            fRHSHistory= JavaPlugin.getDefault().getContentAssistHistory().getHistory(null);
    }
    return fRHSHistory;
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaContentAssistInvocationContext.java   
/**
 * Returns the expected type if any, <code>null</code> otherwise.
 * <p>
 * <strong>Note:</strong> This method may run
 * {@linkplain ICodeAssist#codeComplete(int, org.eclipse.jdt.core.CompletionRequestor) codeComplete}
 * on the compilation unit.
 * </p>
 *
 * @return the expected type if any, <code>null</code> otherwise
 */
public IType getExpectedType() {
    if (fType == null && getCompilationUnit() != null) {
        CompletionContext context= getCoreContext();
        if (context != null) {
            char[][] expectedTypes= context.getExpectedTypesSignatures();
            if (expectedTypes != null && expectedTypes.length > 0) {
                IJavaProject project= getCompilationUnit().getJavaProject();
                if (project != null) {
                    try {
                        fType= project.findType(SignatureUtil.stripSignatureToFQN(String.valueOf(expectedTypes[0])));
                    } catch (JavaModelException x) {
                        JavaPlugin.log(x);
                    }
                }
            }
        }
    }
    return fType;
}
项目:Eclipse-Postfix-Code-Completion    文件:SWTTemplateCompletionProposalComputer.java   
@Override
protected TemplateEngine computeCompletionEngine(JavaContentAssistInvocationContext context) {
    ICompilationUnit unit= context.getCompilationUnit();
    if (unit == null)
        return null;

    IJavaProject javaProject= unit.getJavaProject();
    if (javaProject == null)
        return null;

    if (isSWTOnClasspath(javaProject)) {
        CompletionContext coreContext= context.getCoreContext();
        if (coreContext != null) {
            int tokenLocation= coreContext.getTokenLocation();
            if ((tokenLocation & CompletionContext.TL_MEMBER_START) != 0) {
                return fSWTMembersTemplateEngine;
            }
            if ((tokenLocation & CompletionContext.TL_STATEMENT_START) != 0) {
                return fSWTStatementsTemplateEngine;
            }
        }
        return fSWTTemplateEngine;
    }

    return null;
}
项目:Eclipse-Postfix-Code-Completion    文件:TemplateCompletionProposalComputer.java   
@Override
protected TemplateEngine computeCompletionEngine(JavaContentAssistInvocationContext context) {
    try {
        String partition= TextUtilities.getContentType(context.getDocument(), IJavaPartitions.JAVA_PARTITIONING, context.getInvocationOffset(), true);
        if (partition.equals(IJavaPartitions.JAVA_DOC))
            return fJavadocTemplateEngine;
        else {
            CompletionContext coreContext= context.getCoreContext();
            if (coreContext != null) {
                int tokenLocation= coreContext.getTokenLocation();
                if ((tokenLocation & CompletionContext.TL_MEMBER_START) != 0) {
                    return fJavaMembersTemplateEngine;
                }
                if ((tokenLocation & CompletionContext.TL_STATEMENT_START) != 0) {
                    return fJavaStatementsTemplateEngine;
                }
            }
            return fJavaTemplateEngine;
        }
    } catch (BadLocationException x) {
        return null;
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaContentAssistInvocationContext.java   
/**
 * Returns the {@link CompletionContext core completion context} if available, <code>null</code>
 * otherwise.
 * <p>
 * <strong>Note:</strong> This method may run
 * {@linkplain ICodeAssist#codeComplete(int, org.eclipse.jdt.core.CompletionRequestor) codeComplete}
 * on the compilation unit.
 * </p>
 *
 * @return the core completion context if available, <code>null</code> otherwise
 */
public CompletionContext getCoreContext() {
    if (fCollector != null) {
        CompletionContext context= fCollector.getContext();
        if (context != null) {
            if (fCoreContext == null)
                fCoreContext= context;
            return context;
        }
    }

    if (fCoreContext == null)
        computeKeywordsAndContext(); // Retrieve the context ourselves

    return fCoreContext;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaContentAssistInvocationContext.java   
/**
 * Returns the content assist type history for the expected type.
 *
 * @return the content assist type history for the expected type
 */
private RHSHistory getRHSHistory() {
    if (fRHSHistory == null) {
        CompletionContext context= getCoreContext();
        if (context != null) {
            char[][] expectedTypes= context.getExpectedTypesSignatures();
            if (expectedTypes != null && expectedTypes.length > 0) {
                String expected= SignatureUtil.stripSignatureToFQN(String.valueOf(expectedTypes[0]));
                fRHSHistory= JavaPlugin.getDefault().getContentAssistHistory().getHistory(expected);
            }
        }
        if (fRHSHistory == null)
            fRHSHistory= JavaPlugin.getDefault().getContentAssistHistory().getHistory(null);
    }
    return fRHSHistory;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaContentAssistInvocationContext.java   
/**
 * Returns the expected type if any, <code>null</code> otherwise.
 * <p>
 * <strong>Note:</strong> This method may run
 * {@linkplain ICodeAssist#codeComplete(int, org.eclipse.jdt.core.CompletionRequestor) codeComplete}
 * on the compilation unit.
 * </p>
 *
 * @return the expected type if any, <code>null</code> otherwise
 */
public IType getExpectedType() {
    if (fType == null && getCompilationUnit() != null) {
        CompletionContext context= getCoreContext();
        if (context != null) {
            char[][] expectedTypes= context.getExpectedTypesSignatures();
            if (expectedTypes != null && expectedTypes.length > 0) {
                IJavaProject project= getCompilationUnit().getJavaProject();
                if (project != null) {
                    try {
                        fType= project.findType(SignatureUtil.stripSignatureToFQN(String.valueOf(expectedTypes[0])));
                    } catch (JavaModelException x) {
                        JavaPlugin.log(x);
                    }
                }
            }
        }
    }
    return fType;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:SWTTemplateCompletionProposalComputer.java   
@Override
protected TemplateEngine computeCompletionEngine(JavaContentAssistInvocationContext context) {
    ICompilationUnit unit= context.getCompilationUnit();
    if (unit == null)
        return null;

    IJavaProject javaProject= unit.getJavaProject();
    if (javaProject == null)
        return null;

    if (isSWTOnClasspath(javaProject)) {
        CompletionContext coreContext= context.getCoreContext();
        if (coreContext != null) {
            int tokenLocation= coreContext.getTokenLocation();
            if ((tokenLocation & CompletionContext.TL_MEMBER_START) != 0) {
                return fSWTMembersTemplateEngine;
            }
            if ((tokenLocation & CompletionContext.TL_STATEMENT_START) != 0) {
                return fSWTStatementsTemplateEngine;
            }
        }
        return fSWTTemplateEngine;
    }

    return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:TemplateCompletionProposalComputer.java   
@Override
protected TemplateEngine computeCompletionEngine(JavaContentAssistInvocationContext context) {
    try {
        String partition= TextUtilities.getContentType(context.getDocument(), IJavaPartitions.JAVA_PARTITIONING, context.getInvocationOffset(), true);
        if (partition.equals(IJavaPartitions.JAVA_DOC))
            return fJavadocTemplateEngine;
        else {
            CompletionContext coreContext= context.getCoreContext();
            if (coreContext != null) {
                int tokenLocation= coreContext.getTokenLocation();
                if ((tokenLocation & CompletionContext.TL_MEMBER_START) != 0) {
                    return fJavaMembersTemplateEngine;
                }
                if ((tokenLocation & CompletionContext.TL_STATEMENT_START) != 0) {
                    return fJavaStatementsTemplateEngine;
                }
            }
            return fJavaTemplateEngine;
        }
    } catch (BadLocationException x) {
        return null;
    }
}
项目:eclipse.jdt.ls    文件:CompletionProposalReplacementProvider.java   
public CompletionProposalReplacementProvider(ICompilationUnit compilationUnit, CompletionContext context, int offset, ClientPreferences prefs){
    super();
    this.compilationUnit = compilationUnit;
    this.context = context;
    this.offset = offset;
    this.client = prefs;
}
项目:che    文件:JavaContentAssistInvocationContext.java   
/**
 * Returns the {@link org.eclipse.jdt.core.CompletionContext core completion context} if
 * available, <code>null</code> otherwise.
 *
 * <p><strong>Note:</strong> This method may run {@linkplain
 * org.eclipse.jdt.core.ICodeAssist#codeComplete(int, org.eclipse.jdt.core.CompletionRequestor)
 * codeComplete} on the compilation unit.
 *
 * @return the core completion context if available, <code>null</code> otherwise
 */
public CompletionContext getCoreContext() {
  if (fCollector != null) {
    CompletionContext context = fCollector.getContext();
    if (context != null) {
      if (fCoreContext == null) fCoreContext = context;
      return context;
    }
  }

  if (fCoreContext == null) computeKeywordsAndContext(); // Retrieve the context ourselves

  return fCoreContext;
}
项目:che    文件:ParameterGuessingProposal.java   
/**
 * Creates a {@link ParameterGuessingProposal} or <code>null</code> if the core context isn't
 * available or extended.
 *
 * @param proposal the original completion proposal
 * @param context the currrent context
 * @param fillBestGuess if set, the best guess will be filled in
 * @return a proposal or <code>null</code>
 */
public static ParameterGuessingProposal createProposal(
    CompletionProposal proposal,
    JavaContentAssistInvocationContext context,
    boolean fillBestGuess) {
  CompletionContext coreContext = context.getCoreContext();
  if (coreContext != null && coreContext.isExtended()) {
    return new ParameterGuessingProposal(proposal, context, coreContext, fillBestGuess);
  }
  return null;
}
项目:che    文件:ParameterGuessingProposal.java   
public ParameterGuessingProposal(
    CompletionProposal proposal,
    JavaContentAssistInvocationContext context,
    CompletionContext coreContext,
    boolean fillBestGuess) {
  super(proposal, context);
  fCoreContext = coreContext;
  fFillBestGuess = fillBestGuess;
}
项目:che    文件:TemplateCompletionProposalComputer.java   
@Override
protected TemplateEngine computeCompletionEngine(JavaContentAssistInvocationContext context) {
  try {
    String partition =
        TextUtilities.getContentType(
            context.getDocument(),
            IJavaPartitions.JAVA_PARTITIONING,
            context.getInvocationOffset(),
            true);
    if (partition.equals(IJavaPartitions.JAVA_DOC)) return fJavadocTemplateEngine;
    else {
      CompletionContext coreContext = context.getCoreContext();
      if (coreContext != null) {
        int tokenLocation = coreContext.getTokenLocation();
        if ((tokenLocation & CompletionContext.TL_MEMBER_START) != 0) {
          return fJavaMembersTemplateEngine;
        }
        if ((tokenLocation & CompletionContext.TL_STATEMENT_START) != 0) {
          return fJavaStatementsTemplateEngine;
        }
      }
      return fJavaTemplateEngine;
    }
  } catch (BadLocationException x) {
    return null;
  }
}
项目:gwt-eclipse-plugin    文件:JavaContentAssistUtilities.java   
/**
 * Generates an {@link IJavaCompletionProposal} from Java's
 * {@link CompletionProposal}.
 * 
 * @param completionProposal the {@link CompletionProposal}
 * @param completionContext the context of the {@link CompletionProposal}
 * @param javaProject the java project for the given completion proposal
 * @return a {@link IJavaCompletionProposal}, or null
 */
public static IJavaCompletionProposal getJavaCompletionProposal(
    CompletionProposal completionProposal,
    CompletionContext completionContext, IJavaProject javaProject) {
  CompletionProposalCollector collector = new CompletionProposalCollector(
      javaProject);
  collector.acceptContext(completionContext);
  collector.accept(completionProposal);
  IJavaCompletionProposal[] javaCompletionProposals = collector.getJavaCompletionProposals();
  return javaCompletionProposals.length > 0 ? javaCompletionProposals[0]
      : null;
}
项目:Eclipse-Postfix-Code-Completion    文件:InternalCompletionProposal.java   
public boolean canUseDiamond(CompletionContext coreContext) {
    if (this.getKind() != CONSTRUCTOR_INVOCATION) return false;
    if (coreContext instanceof InternalCompletionContext) {
        InternalCompletionContext internalCompletionContext = (InternalCompletionContext) coreContext;
        if (internalCompletionContext.extendedContext == null) return false;
        char[] name1 = this.declarationPackageName;
        char[] name2 = this.declarationTypeName;
        char[] declarationType = CharOperation.concat(name1, name2, '.');  // fully qualified name
        // even if the type arguments used in the method have been substituted,
        // extract the original type arguments only, since thats what we want to compare with the class
        // type variables (Substitution might have happened when the constructor is coming from another
        // CU and not the current one).
        char[] sign = (this.originalSignature != null)? this.originalSignature : getSignature();
        if (!(sign == null || sign.length < 2)) {
            sign = Signature.removeCapture(sign);
        }
        char[][] types= Signature.getParameterTypes(sign);
        String[] paramTypeNames= new String[types.length];
        for (int i= 0; i < types.length; i++) {
            paramTypeNames[i]= new String(Signature.toCharArray(types[i]));
        }
        return internalCompletionContext.extendedContext.canUseDiamond(paramTypeNames,declarationType);
    }
    else {
        return false;
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:InternalCompletionProposal.java   
public boolean canUseDiamond(CompletionContext coreContext) {
    if (this.getKind() != CONSTRUCTOR_INVOCATION) return false;
    if (coreContext instanceof InternalCompletionContext) {
        InternalCompletionContext internalCompletionContext = (InternalCompletionContext) coreContext;
        if (internalCompletionContext.extendedContext == null) return false;
        char[] name1 = this.declarationPackageName;
        char[] name2 = this.declarationTypeName;
        char[] declarationType = CharOperation.concat(name1, name2, '.');  // fully qualified name
        // even if the type arguments used in the method have been substituted,
        // extract the original type arguments only, since thats what we want to compare with the class
        // type variables (Substitution might have happened when the constructor is coming from another
        // CU and not the current one).
        char[] sign = (this.originalSignature != null)? this.originalSignature : getSignature();
        if (!(sign == null || sign.length < 2)) {
            sign = Signature.removeCapture(sign);
        }
        char[][] types= Signature.getParameterTypes(sign);
        String[] paramTypeNames= new String[types.length];
        for (int i= 0; i < types.length; i++) {
            paramTypeNames[i]= new String(Signature.toCharArray(types[i]));
        }
        return internalCompletionContext.extendedContext.canUseDiamond(paramTypeNames,declarationType);
    }
    else {
        return false;
    }
}
项目:saneclipse    文件:JFaceCompletionProposalComputer.java   
@Override
protected TemplateEngine computeCompletionEngine(JavaContentAssistInvocationContext context) {
    final ICompilationUnit unit = context.getCompilationUnit();
    if (unit == null) {
        return null;
    }

    final IJavaProject javaProject = unit.getJavaProject();
    if (javaProject == null) {
        return null;
    }

    if (isJFaceOnClasspath(javaProject)) {
        final CompletionContext coreContext = context.getCoreContext();
        if (coreContext != null) {
            final int tokenLocation = coreContext.getTokenLocation();
            if ((tokenLocation & CompletionContext.TL_MEMBER_START) != 0) {
                return jFaceMembersTemplateEngine;
            }
            if ((tokenLocation & CompletionContext.TL_STATEMENT_START) != 0) {
                return jFaceStatementsTemplateEngine;
            }
        }
        return jFaceTemplateEngine;
    }

    return null;
}
项目:eclipse.jdt.ls    文件:CompletionProposalDescriptionProvider.java   
/**
 * Creates a new label provider.
 * @param iCompilationUnit
 */
public CompletionProposalDescriptionProvider(CompletionContext context) {
    super();
    fContext = context;
}
项目:eclipse.jdt.ls    文件:CompletionProposalRequestor.java   
@Override
public void acceptContext(CompletionContext context) {
    super.acceptContext(context);
    response.setContext(context);
    this.descriptionProvider = new CompletionProposalDescriptionProvider(context);
}
项目:eclipse.jdt.ls    文件:SignatureHelpRequestor.java   
@Override
public void acceptContext(CompletionContext context) {
    super.acceptContext(context);
    response.setContext(context);
    this.descriptionProvider = new CompletionProposalDescriptionProvider(context);
}
项目:eclipse.jdt.ls    文件:CompletionResponse.java   
/**
 * @return the context
 */
public CompletionContext getContext() {
    return context;
}
项目:eclipse.jdt.ls    文件:CompletionResponse.java   
/**
 * @param context the context to set
 */
public void setContext(CompletionContext context) {
    this.context = context;
}
项目:gwt-eclipse-plugin    文件:ProposalGeneratingCompletionRequestor.java   
@Override
public void acceptContext(CompletionContext context) {
  this.context = context;
}
项目:gwt-eclipse-plugin    文件:ProposalGeneratingCompletionRequestor.java   
public CompletionContext getContext() {
  return context;
}
项目:Eclipse-Postfix-Code-Completion    文件:ParameterGuessingProposal.java   
public ParameterGuessingProposal(CompletionProposal proposal, JavaContentAssistInvocationContext context, CompletionContext coreContext, boolean fillBestGuess) {
    super(proposal, context);
fCoreContext= coreContext;
fFillBestGuess= fillBestGuess;
}
项目:Eclipse-Postfix-Code-Completion    文件:CompletionEngine.java   
private void buildTokenLocationContext(InternalCompletionContext context, Scope scope, ASTNode astNode, ASTNode astNodeParent) {
    if (scope == null || context.isInJavadoc()) return;

    if (astNode instanceof CompletionOnFieldType) {
        CompletionOnFieldType field = (CompletionOnFieldType) astNode;
        if (!field.isLocalVariable &&
                field.modifiers == ClassFileConstants.AccDefault &&
                (field.annotations == null || field.annotations.length == 0)) {
            context.setTokenLocation(CompletionContext.TL_MEMBER_START);
        }
    } else if (astNode instanceof CompletionOnMethodReturnType) {
        CompletionOnMethodReturnType method = (CompletionOnMethodReturnType) astNode;
        if (method.modifiers == ClassFileConstants.AccDefault &&
                (method.annotations == null || method.annotations.length == 0)) {
            context.setTokenLocation(CompletionContext.TL_MEMBER_START);
        }
    } else if (astNode instanceof CompletionOnSingleTypeReference) {
        CompletionOnSingleTypeReference completionOnSingleTypeReference = (CompletionOnSingleTypeReference) astNode;
        if (completionOnSingleTypeReference.isConstructorType) {
                    context.setTokenLocation(CompletionContext.TL_CONSTRUCTOR_START);
        }
    } else if (astNode instanceof CompletionOnQualifiedTypeReference) {
        CompletionOnQualifiedTypeReference completionOnQualifiedTypeReference = (CompletionOnQualifiedTypeReference) astNode;
        if (completionOnQualifiedTypeReference.isConstructorType){
                    context.setTokenLocation(CompletionContext.TL_CONSTRUCTOR_START);
        }
    } else {
        ReferenceContext referenceContext = scope.referenceContext();
        if (referenceContext instanceof AbstractMethodDeclaration) {
            AbstractMethodDeclaration methodDeclaration = (AbstractMethodDeclaration)referenceContext;
            if (methodDeclaration.bodyStart <= astNode.sourceStart &&
                    astNode.sourceEnd <= methodDeclaration.bodyEnd) {
                // completion is inside a method body
                if (astNodeParent == null &&
                        astNode instanceof CompletionOnSingleNameReference &&
                        !((CompletionOnSingleNameReference)astNode).isPrecededByModifiers) {
                    context.setTokenLocation(CompletionContext.TL_STATEMENT_START);
                }
            }
        } else if (referenceContext instanceof LambdaExpression) {
            LambdaExpression expression = (LambdaExpression)referenceContext;
            if (expression.body().sourceStart <= astNode.sourceStart &&
                    astNode.sourceEnd <= expression.body().sourceEnd) {
                // completion is inside a method body
                if (astNodeParent == null &&
                        astNode instanceof CompletionOnSingleNameReference &&
                        !((CompletionOnSingleNameReference)astNode).isPrecededByModifiers) {
                    context.setTokenLocation(CompletionContext.TL_STATEMENT_START);
                }
            }
        } else if (referenceContext instanceof TypeDeclaration) {
            TypeDeclaration typeDeclaration = (TypeDeclaration) referenceContext;
            FieldDeclaration[] fields = typeDeclaration.fields;
            if (fields != null) {
                done : for (int i = 0; i < fields.length; i++) {
                    if (fields[i] instanceof Initializer) {
                        Initializer initializer = (Initializer) fields[i];
                        if (initializer.block.sourceStart <= astNode.sourceStart &&
                                astNode.sourceStart < initializer.bodyEnd) {
                            // completion is inside an initializer
                            if (astNodeParent == null &&
                                    astNode instanceof CompletionOnSingleNameReference &&
                                    !((CompletionOnSingleNameReference)astNode).isPrecededByModifiers) {
                                context.setTokenLocation(CompletionContext.TL_STATEMENT_START);
                            }
                            break done;
                        }
                    }
                }
            }
        }
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:PostfixCompletionProposalComputer.java   
@Override
protected TemplateEngine computeCompletionEngine(JavaContentAssistInvocationContext context) {
    ICompilationUnit unit = context.getCompilationUnit();
    if (unit == null)
        return null;

    IJavaProject javaProject = unit.getJavaProject();
    if (javaProject == null)
        return null;

    CompletionContext coreContext = context.getCoreContext();
    if (coreContext != null) {
        int tokenLocation= coreContext.getTokenLocation();
        int tokenStart= coreContext.getTokenStart();
        int tokenKind= coreContext.getTokenKind();

        /*
        // XXX print out tokenlocation stuff (debugging)
        System.out.println("All Tokens: " + CompletionContext.TL_CONSTRUCTOR_START + " " + CompletionContext.TL_MEMBER_START + " " + CompletionContext.TL_STATEMENT_START);
        System.out.println("Token Start: " + coreContext.getTokenStart());
        System.out.println("Token End: " + coreContext.getTokenEnd());
        System.out.println("Token Kind: " + coreContext.getTokenKind());
        System.out.println("Token Location: " + coreContext.getTokenLocation());
        System.out.println("Enclosing Element: " + coreContext.getEnclosingElement());
        System.out.println("Offset: " + coreContext.getOffset());
        System.out.println("Token Array: " + Arrays.toString(coreContext.getToken()));
        System.out.println("Kind Tokens: " + CompletionContext.TOKEN_KIND_NAME + ", " + CompletionContext.TOKEN_KIND_STRING_LITERAL + ", " + CompletionContext.TOKEN_KIND_UNKNOWN);
        */
        if (context.getViewer().getSelectedRange().y > 0) { // If there is an active selection we do not want to contribute to the CA
            return null;
        }

        if ((tokenLocation == 0 && tokenStart > -1)
                || ((tokenLocation & CompletionContext.TL_MEMBER_START) != 0 && tokenKind == CompletionContext.TOKEN_KIND_NAME && tokenStart > -1)
                || (tokenLocation == 0 && isAfterDot(context.getDocument(), context.getInvocationOffset()))) {

            analyzeCoreContext(context, coreContext);

            return postfixCompletionTemplateEngine;
        }
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ParameterGuessingProposal.java   
private ParameterGuessingProposal(CompletionProposal proposal, JavaContentAssistInvocationContext context, CompletionContext coreContext, boolean fillBestGuess) {
    super(proposal, context);
fCoreContext= coreContext;
fFillBestGuess= fillBestGuess;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CompletionEngine.java   
private void buildTokenLocationContext(InternalCompletionContext context, Scope scope, ASTNode astNode, ASTNode astNodeParent) {
    if (scope == null || context.isInJavadoc()) return;

    if (astNode instanceof CompletionOnFieldType) {
        CompletionOnFieldType field = (CompletionOnFieldType) astNode;
        if (!field.isLocalVariable &&
                field.modifiers == ClassFileConstants.AccDefault &&
                (field.annotations == null || field.annotations.length == 0)) {
            context.setTokenLocation(CompletionContext.TL_MEMBER_START);
        }
    } else if (astNode instanceof CompletionOnMethodReturnType) {
        CompletionOnMethodReturnType method = (CompletionOnMethodReturnType) astNode;
        if (method.modifiers == ClassFileConstants.AccDefault &&
                (method.annotations == null || method.annotations.length == 0)) {
            context.setTokenLocation(CompletionContext.TL_MEMBER_START);
        }
    } else {
        ReferenceContext referenceContext = scope.referenceContext();
        if (referenceContext instanceof AbstractMethodDeclaration) {
            AbstractMethodDeclaration methodDeclaration = (AbstractMethodDeclaration)referenceContext;
            if (methodDeclaration.bodyStart <= astNode.sourceStart &&
                    astNode.sourceEnd <= methodDeclaration.bodyEnd) {
                // completion is inside a method body
                if (astNodeParent == null &&
                        astNode instanceof CompletionOnSingleNameReference &&
                        !((CompletionOnSingleNameReference)astNode).isPrecededByModifiers) {
                    context.setTokenLocation(CompletionContext.TL_STATEMENT_START);
                }
            }
        } else if (referenceContext instanceof TypeDeclaration) {
            TypeDeclaration typeDeclaration = (TypeDeclaration) referenceContext;
            FieldDeclaration[] fields = typeDeclaration.fields;
            if (fields != null) {
                done : for (int i = 0; i < fields.length; i++) {
                    if (fields[i] instanceof Initializer) {
                        Initializer initializer = (Initializer) fields[i];
                        if (initializer.block.sourceStart <= astNode.sourceStart &&
                                astNode.sourceStart < initializer.bodyEnd) {
                            // completion is inside an initializer
                            if (astNodeParent == null &&
                                    astNode instanceof CompletionOnSingleNameReference &&
                                    !((CompletionOnSingleNameReference)astNode).isPrecededByModifiers) {
                                context.setTokenLocation(CompletionContext.TL_STATEMENT_START);
                            }
                            break done;
                        }
                    }
                }
            }
        }
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:PostfixCompletionProposalComputer.java   
@Override
protected TemplateEngine computeCompletionEngine(JavaContentAssistInvocationContext context) {
    ICompilationUnit unit = context.getCompilationUnit();
    if (unit == null)
        return null;

    IJavaProject javaProject = unit.getJavaProject();
    if (javaProject == null)
        return null;

    CompletionContext coreContext = context.getCoreContext();
    if (coreContext != null) {
        int tokenLocation= coreContext.getTokenLocation();
        int tokenStart= coreContext.getTokenStart();
        int tokenKind= coreContext.getTokenKind();

        /*
        // XXX print out tokenlocation stuff (debugging)
        System.out.println("All Tokens: " + CompletionContext.TL_CONSTRUCTOR_START + " " + CompletionContext.TL_MEMBER_START + " " + CompletionContext.TL_STATEMENT_START);
        System.out.println("Token Start: " + coreContext.getTokenStart());
        System.out.println("Token End: " + coreContext.getTokenEnd());
        System.out.println("Token Kind: " + coreContext.getTokenKind());
        System.out.println("Token Location: " + coreContext.getTokenLocation());
        System.out.println("Enclosing Element: " + coreContext.getEnclosingElement());
        System.out.println("Offset: " + coreContext.getOffset());
        System.out.println("Token Array: " + Arrays.toString(coreContext.getToken()));
        System.out.println("Kind Tokens: " + CompletionContext.TOKEN_KIND_NAME + ", " + CompletionContext.TOKEN_KIND_STRING_LITERAL + ", " + CompletionContext.TOKEN_KIND_UNKNOWN);
        */
        if (context.getViewer().getSelectedRange().y > 0) { // If there is an active selection we do not want to contribute to the CA
            return null;
        }

        if ((tokenLocation == 0 && tokenStart > -1)
                || ((tokenLocation & CompletionContext.TL_MEMBER_START) != 0 && tokenKind == CompletionContext.TOKEN_KIND_NAME && tokenStart > -1)
                || (tokenLocation == 0 && isAfterDot(context.getDocument(), context.getInvocationOffset()))) {

            analyzeCoreContext(context, coreContext);

            return postfixCompletionTemplateEngine;
        }
    }
    return null;
}
项目:NTNU-Master-Project    文件:AkkaCompletionRequestor.java   
@Override
    public void acceptContext(CompletionContext context) {
        super.acceptContext(context);

//      System.out.println("[2] acceptContext:" + context);
    }
项目:masteroppgave    文件:AkkaCompletionRequestor.java   
@Override
    public void acceptContext(CompletionContext context) {
        super.acceptContext(context);

//      System.out.println("[2] acceptContext:" + context);
    }
项目:Eclipse-Postfix-Code-Completion    文件:ParameterGuessingProposal.java   
/**
 * Creates a {@link ParameterGuessingProposal} or <code>null</code> if the core context isn't available or extended.
 *
 * @param proposal the original completion proposal
 * @param context the currrent context
 * @param fillBestGuess if set, the best guess will be filled in
 *
 * @return a proposal or <code>null</code>
 */
public static ParameterGuessingProposal createProposal(CompletionProposal proposal, JavaContentAssistInvocationContext context, boolean fillBestGuess) {
    CompletionContext coreContext= context.getCoreContext();
        if (coreContext != null && coreContext.isExtended()) {
        return new ParameterGuessingProposal(proposal, context, coreContext, fillBestGuess);
        }
        return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ParameterGuessingProposal.java   
/**
 * Creates a {@link ParameterGuessingProposal} or <code>null</code> if the core context isn't available or extended.
 *
 * @param proposal the original completion proposal
 * @param context the currrent context
 * @param fillBestGuess if set, the best guess will be filled in
 *
 * @return a proposal or <code>null</code>
 */
public static ParameterGuessingProposal createProposal(CompletionProposal proposal, JavaContentAssistInvocationContext context, boolean fillBestGuess) {
    CompletionContext coreContext= context.getCoreContext();
        if (coreContext != null && coreContext.isExtended()) {
        return new ParameterGuessingProposal(proposal, context, coreContext, fillBestGuess);
        }
        return null;
}
项目:che    文件:CompletionProposalLabelProvider.java   
/**
 * Sets the completion context.
 *
 * @param context the completion context
 * @since 3.2
 */
void setContext(CompletionContext context) {
  fContext = context;
}
项目:che    文件:CompletionProposalCollector.java   
/**
 * {@inheritDoc}
 *
 * <p>Subclasses may extend, but usually should not need to.
 *
 * @see #getContext()
 */
@Override
public void acceptContext(CompletionContext context) {
  fContext = context;
  fLabelProvider.setContext(context);
}