Example usage for org.eclipse.jdt.internal.core InternalNamingConventions BK_SIMPLE_TYPE_NAME

List of usage examples for org.eclipse.jdt.internal.core InternalNamingConventions BK_SIMPLE_TYPE_NAME

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core InternalNamingConventions BK_SIMPLE_TYPE_NAME.

Prototype

int BK_SIMPLE_TYPE_NAME

To view the source code for org.eclipse.jdt.internal.core InternalNamingConventions BK_SIMPLE_TYPE_NAME.

Click Source Link

Usage

From source file:org.codehaus.groovy.eclipse.codeassist.processors.NewFieldCompletionProcessor.java

License:Apache License

public List<ICompletionProposal> generateProposals(IProgressMonitor monitor) {
    ContentAssistContext context = getContext();
    List<String> unimplementedFieldNames = getAllSuggestedFieldNames(context);
    List<ICompletionProposal> proposals = new LinkedList<ICompletionProposal>();
    IType enclosingType = context.getEnclosingType();
    if (enclosingType != null) {
        for (String fieldName : unimplementedFieldNames) {
            proposals.add(createProposal(fieldName, context, enclosingType));
        }//from www.j a v a2  s . com
        // next check to see if we are at a partially completed field
        // declaration,
        // ie- is the type specified, but the name is not (or is only
        // partially specified)?
        NameAndLocation nameAndLocation = findCompletionTypeName(context.unit, context.completionLocation);
        if (nameAndLocation != null) {
            String typeName = nameAndLocation.toTypeName();
            if (typeName.equals("def")) {
                typeName = "value";
            }
            String[] suggestedNames = NamingConventions.suggestVariableNames(
                    NamingConventions.VK_INSTANCE_FIELD, InternalNamingConventions.BK_SIMPLE_TYPE_NAME,
                    typeName, context.unit.getJavaProject(), nameAndLocation.dims(), null, true);
            if (suggestedNames != null) {
                for (String suggestedName : suggestedNames) {
                    if (suggestedName.startsWith(context.completionExpression)) {
                        proposals.add(createProposal(suggestedName, nameAndLocation.name, context,
                                enclosingType, false, true, nameAndLocation.location,
                                context.completionLocation - nameAndLocation.location));
                    }
                }
            }
        }
    }

    return proposals;
}