Example usage for org.eclipse.jdt.internal.core SourceField SourceField

List of usage examples for org.eclipse.jdt.internal.core SourceField SourceField

Introduction

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

Prototype

protected SourceField(JavaElement parent, String name) 

Source Link

Document

Constructs a handle to the field with the given name in the specified type.

Usage

From source file:org.dozer.eclipse.plugin.editorpage.utils.StringToFieldConverter.java

License:Apache License

public Object convert(Object fromObject) {
    String fieldName = fromObject.toString();

    if (fieldName == null || "".equals(fieldName))
        return null;

    for (IField field : existingFields) {
        if (field.getElementName().equals(fieldName)) {
            return field;
        }//from w  ww.j  a  v  a2  s . co  m
    }

    if (fakeField != null)
        existingFields.remove(fakeField);

    fakeField = new SourceField(null, fieldName) {
    };
    existingFields.add(fakeField);

    viewer.refresh();

    return fakeField;
}

From source file:org.eclipse.ajdt.core.javaelements.FieldIntertypeElement.java

License:Open Source License

@Override
public IMember createMockDeclaration(IType parent) {
    try {/*from   www .j  a v  a2s .  c  o m*/
        final IntertypeElementInfo info = (IntertypeElementInfo) getElementInfo();
        IField itd = new SourceField((JavaElement) parent, getTargetName()) {
            protected Object createElementInfo() {
                /* AJDT 1.7 */
                ITDSourceFieldElementInfo newInfo = new ITDSourceFieldElementInfo(FieldIntertypeElement.this,
                        info.getChildren());
                newInfo.setFlags(CompilationUnitTools.getPublicModifierCode(info));
                newInfo.setNameSourceEnd(info.getNameSourceEnd());
                newInfo.setNameSourceStart(info.getNameSourceStart());
                newInfo.setTypeName(getQualifiedReturnTypeName(info));
                newInfo.setSourceRangeStart(info.getSourceRange().getOffset());
                newInfo.setSourceRangeEnd(
                        info.getSourceRange().getOffset() + info.getSourceRange().getLength());
                return newInfo;
            }

            public boolean exists() {
                return true;
            }
        };
        return itd;
    } catch (JavaModelException e) {
    }
    return null;
}