コード例 #1
0
 /**
  * Resolves the member described by the receiver and returns it if found. Returns <code>null
  * </code> if no corresponding member can be found.
  *
  * @return the resolved member or <code>null</code> if none is found
  * @throws DartModelException if accessing the Dart model fails
  */
 @SuppressWarnings("deprecation")
 protected Type resolveType() throws DartModelException {
   String typeName = String.valueOf(proposal.getSignature());
   Type type = project.findType(typeName);
   if (type == null) {
     type = project.findType(new String(proposal.getCompletion()));
   }
   return type;
 }
コード例 #2
0
 /**
  * Returns the type signature of the declaring type of a <code>CompletionProposal</code>, or
  * <code>null</code> for proposals that do not have a declaring type. The return value is
  * <em>not</em> <code>null</code> for proposals of the following kinds:
  *
  * <ul>
  *   <li>METHOD_DECLARATION
  *   <li>METHOD_NAME_REFERENCE
  *   <li>METHOD_REF
  *   <li>ANNOTATION_ATTRIBUTE_REF
  *   <li>POTENTIAL_METHOD_DECLARATION
  *   <li>ANONYMOUS_CLASS_DECLARATION
  *   <li>FIELD_REF
  *   <li>PACKAGE_REF (returns the package, but no type)
  *   <li>TYPE_REF
  * </ul>
  *
  * @param proposal the completion proposal to get the declaring type for
  * @return the type signature of the declaring type, or <code>null</code> if there is none
  */
 protected final char[] getDeclaringType(CompletionProposal proposal) {
   switch (proposal.getKind()) {
     case CompletionProposal.METHOD_DECLARATION:
     case CompletionProposal.METHOD_NAME_REFERENCE:
       //      case CompletionProposal.JAVADOC_METHOD_REF:
     case CompletionProposal.METHOD_REF:
     case CompletionProposal.ARGUMENT_LIST:
     case CompletionProposal.CONSTRUCTOR_INVOCATION:
       //      case CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION:
       //      case CompletionProposal.METHOD_REF_WITH_CASTED_RECEIVER:
       //      case CompletionProposal.ANNOTATION_ATTRIBUTE_REF:
     case CompletionProposal.POTENTIAL_METHOD_DECLARATION:
       //      case CompletionProposal.ANONYMOUS_CLASS_DECLARATION:
     case CompletionProposal.FIELD_REF:
       //      case CompletionProposal.FIELD_REF_WITH_CASTED_RECEIVER:
       //      case CompletionProposal.JAVADOC_FIELD_REF:
       //      case CompletionProposal.JAVADOC_VALUE_REF:
       char[] declaration = proposal.getDeclarationSignature();
       // special methods may not have a declaring type: methods defined on arrays etc.
       // Currently known: class literals don't have a declaring type - use Object
       //        if (declaration == null) {
       //          return "java.lang.Object".toCharArray(); //$NON-NLS-1$
       //        }
       return Signature.toCharArray(declaration);
     case CompletionProposal.LIBRARY_PREFIX:
       return proposal.getDeclarationSignature();
       //      case CompletionProposal.JAVADOC_TYPE_REF:
     case CompletionProposal.TYPE_REF:
       return Signature.toCharArray(proposal.getSignature());
     case CompletionProposal.LOCAL_VARIABLE_REF:
     case CompletionProposal.VARIABLE_DECLARATION:
     case CompletionProposal.KEYWORD:
     case CompletionProposal.LABEL_REF:
     case CompletionProposal.TYPE_IMPORT:
     case CompletionProposal.OPTIONAL_ARGUMENT:
     case CompletionProposal.NAMED_ARGUMENT:
       //      case CompletionProposal.JAVADOC_BLOCK_TAG:
       //      case CompletionProposal.JAVADOC_INLINE_TAG:
       //      case CompletionProposal.JAVADOC_PARAM_REF:
       return null;
     default:
       Assert.isTrue(false);
       return null;
   }
 }
コード例 #3
0
  private IDartCompletionProposal createMethodDeclarationProposal(CompletionProposal proposal) {
    if (fCompilationUnit == null || fDartProject == null) {
      return null;
    }

    String name = String.valueOf(proposal.getName());
    String[] paramTypes = Signature.getParameterTypes(String.valueOf(proposal.getSignature()));
    for (int index = 0; index < paramTypes.length; index++) {
      paramTypes[index] = Signature.toString(paramTypes[index]);
    }
    int start = proposal.getReplaceStart();
    int length = getLength(proposal);

    StyledString label =
        new StyledString(
            fLabelProvider.createOverrideMethodProposalLabel(proposal)); // TODO(messick)

    DartCompletionProposal dartProposal =
        new OverrideCompletionProposal(
            fDartProject,
            fCompilationUnit,
            name,
            paramTypes,
            start,
            length,
            getLengthIdentifier(proposal),
            label,
            String.valueOf(proposal.getCompletion()));
    dartProposal.setImage(getImage(fLabelProvider.createMethodImageDescriptor(proposal)));
    // TODO(scheglov) implement documentation comment
    //    dartProposal.setProposalInfo(new MethodProposalInfo(fDartProject, proposal));
    dartProposal.setRelevance(computeRelevance(proposal));

    fSuggestedMethodNames.add(new String(name));
    return dartProposal;
  }