Example usage for org.eclipse.jdt.core NamingConventions VK_INSTANCE_FIELD

List of usage examples for org.eclipse.jdt.core NamingConventions VK_INSTANCE_FIELD

Introduction

In this page you can find the example usage for org.eclipse.jdt.core NamingConventions VK_INSTANCE_FIELD.

Prototype

int VK_INSTANCE_FIELD

To view the source code for org.eclipse.jdt.core NamingConventions VK_INSTANCE_FIELD.

Click Source Link

Document

Variable kind which represents an instance field.

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  ava 2s.  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;
}

From source file:org.eclipse.xtext.common.types.xtext.ui.JdtVariableCompletions.java

License:Open Source License

protected int getVariableKind(VariableType varType) {
    switch (varType) {
    case INSTANCE_FIELD:
        return NamingConventions.VK_INSTANCE_FIELD;
    case LOCAL_VAR:
        return NamingConventions.VK_LOCAL;
    case PARAMETER:
        return NamingConventions.VK_PARAMETER;
    case STATIC_FIELD:
        return NamingConventions.VK_STATIC_FINAL_FIELD;
    default://from   ww  w.j a v a2  s .  c  o  m
        throw new IllegalStateException("unhandled enum const" + varType);
    }
}