本文整理汇总了Java中org.eclipse.jdt.core.IField类的典型用法代码示例。如果您正苦于以下问题:Java IField类的具体用法?Java IField怎么用?Java IField使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IField类属于org.eclipse.jdt.core包,在下文中一共展示了IField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveMember
import org.eclipse.jdt.core.IField; //导入依赖的package包/类
/**
* 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 org.eclipse.jdt.core.JavaModelException if accessing the java model fails
*/
@Override
protected IMember resolveMember() throws JavaModelException {
char[] declarationSignature = fProposal.getDeclarationSignature();
// for synthetic fields on arrays, declaration signatures may be null
// TODO remove when https://bugs.eclipse.org/bugs/show_bug.cgi?id=84690 gets fixed
if (declarationSignature == null) return null;
String typeName = SignatureUtil.stripSignatureToFQN(String.valueOf(declarationSignature));
IType type = fJavaProject.findType(typeName);
if (type != null) {
String name = String.valueOf(fProposal.getName());
IField field = type.getField(name);
if (field.exists()) return field;
}
return null;
}
示例2: execute
import org.eclipse.jdt.core.IField; //导入依赖的package包/类
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final IEditorPart editorPart = HandlerUtil.getActiveEditor(event);
final ICompilationUnit icu = JavaUI.getWorkingCopyManager().getWorkingCopy(editorPart.getEditorInput());
try {
final IType type = icu.getTypes()[0];
final List<Field> fields = new ArrayList<>();
for (final IField field : type.getFields()) {
final String fieldName = field.getElementName();
final String fieldType = Signature.getSignatureSimpleName(field.getTypeSignature());
fields.add(new Field(fieldName, fieldType));
}
new WizardDialog(HandlerUtil.getActiveShell(event), new BuilderGeneratorWizard(icu, fields)).open();
}
catch (final JavaModelException e) {
e.printStackTrace();
}
return null;
}
示例3: addRefCombovalues
import org.eclipse.jdt.core.IField; //导入依赖的package包/类
private void addRefCombovalues(Combo combo, String paramType) {
if(!PrimitiveType.isPrimitiveSig(paramType)) {
combo.add("null");
IType owner = (IType) method.getParent();
try {
IField[] fields = owner.getFields();
for(IField f : fields)
if(Flags.isStatic(f.getFlags()) && f.getTypeSignature().equals(paramType))
combo.add(f.getElementName());
} catch (JavaModelException e1) {
e1.printStackTrace();
}
}
}
示例4: addCombovalues
import org.eclipse.jdt.core.IField; //导入依赖的package包/类
private void addCombovalues(Combo combo, String paramType) {
if(!PrimitiveType.isPrimitiveSig(paramType)) {
String sel = combo.getText();
combo.removeAll();
combo.add("null");
IType owner = (IType) method.getParent();
try {
IField[] fields = owner.getFields();
for(IField f : fields)
if(Flags.isStatic(f.getFlags()) && f.getTypeSignature().equals(paramType))
combo.add(f.getElementName());
} catch (JavaModelException e1) {
e1.printStackTrace();
}
if(sel.isEmpty())
combo.select(0);
else
combo.setText(sel);
}
}
示例5: getMemberCandidates
import org.eclipse.jdt.core.IField; //导入依赖的package包/类
private List<IMember> getMemberCandidates(IType type, Bookmark javaBookmark) {
String elementKind = javaBookmark.getPropertyValue(PROP_JAVA_ELEMENT_KIND);
String elementName = javaBookmark.getPropertyValue(PROP_JAVA_ELEMENT_NAME);
if (KIND_FIELD.equals(elementKind)) {
IField field = type.getField(elementName);
return field.exists() ? Lists.newArrayList(field) : Collections.emptyList();
}
if (KIND_METHOD.equals(elementKind)) {
String signature = javaBookmark.getPropertyValue(PROP_JAVA_METHOD_SIGNATURE);
IMethod method = null;
if (signature != null) {
method = getMethod(type, elementName, signature);
}
if (method == null) {
List<IMethod> candidates = getMethodsWithName(type, elementName);
return Lists.newArrayList(candidates);
}
return Lists.newArrayList(method);
}
if (JavaEditorUtils.isType(elementKind) && elementName != null) {
IType memberType = type.getType(elementName);
return memberType.exists() ? Lists.newArrayList(memberType) : Collections.emptyList();
}
return Collections.emptyList();
}
示例6: addMemberBookmarkProperties
import org.eclipse.jdt.core.IField; //导入依赖的package包/类
protected void addMemberBookmarkProperties(Map<String, String> bookmarkProperties, IMember member) {
putIfAbsent(bookmarkProperties, PROP_JAVA_ELEMENT_NAME, member.getElementName());
if (member.getDeclaringType() != null) {
putIfAbsent(bookmarkProperties, PROP_JAVA_DECLARING_TYPE,
member.getDeclaringType().getFullyQualifiedName());
}
putIfAbsent(bookmarkProperties, PROP_JAVA_ELEMENT_KIND, getKind(member));
if (member instanceof IMethod) {
putIfAbsent(bookmarkProperties, PROP_JAVA_METHOD_SIGNATURE,
JavaEditorUtils.getMethodSimpleSignature((IMethod) member));
putIfAbsent(bookmarkProperties, Bookmark.PROPERTY_NAME,
bookmarkProperties.get(PROP_JAVA_DECLARING_TYPE) + '.' + member.getElementName() + "()");
}
if (member instanceof IType) {
IType type = (IType) member;
putIfAbsent(bookmarkProperties, PROP_JAVA_TYPE, type.getFullyQualifiedName());
putIfAbsent(bookmarkProperties, Bookmark.PROPERTY_NAME, type.getFullyQualifiedName());
}
if (member instanceof IField) {
putIfAbsent(bookmarkProperties, Bookmark.PROPERTY_NAME,
bookmarkProperties.get(PROP_JAVA_DECLARING_TYPE) + '.' + member.getElementName());
}
putIfAbsent(bookmarkProperties, Bookmark.PROPERTY_NAME, member.getElementName());
}
示例7: visit
import org.eclipse.jdt.core.IField; //导入依赖的package包/类
@Override
public boolean visit(FieldDeclaration fieldDeclaration) {
List<VariableDeclarationFragment> fragments = fieldDeclaration.fragments();
for (VariableDeclarationFragment fragment : fragments) {
IVariableBinding binding = fragment.resolveBinding();
if (binding == null)
continue;
IField field = (IField) binding.getJavaElement();
FieldDetails fieldDetails = new FieldDetails();
fieldDetails.setModifiers(fieldDeclaration.getModifiers());
allDetails.put(field.getHandleIdentifier(), fieldDetails);
}
return true;
}
示例8: getTypesToFilter
import org.eclipse.jdt.core.IField; //导入依赖的package包/类
private List<String> getTypesToFilter(IStructuredSelection selection) {
if (selection == null) {
return null;
}
List<String> typesToFilter = new ArrayList<String>();
for (Iterator<?> iterator = selection.iterator(); iterator.hasNext();) {
Object elt = iterator.next();
if(elt instanceof TreeElement<?,?>){
elt = ((TreeElement)elt).getJavaElement();
}
if (elt instanceof IField) {
IField field = (IField) elt;
String resolvedType = SearchUtils.getResolvedType(field);
if (resolvedType != null) {
typesToFilter.add(resolvedType);
}
} else if(elt instanceof IType){
IType type = (IType) elt;
typesToFilter.add(type.getFullyQualifiedName());
}
}
return typesToFilter;
}
示例9: createEnumTypeNameField
import org.eclipse.jdt.core.IField; //导入依赖的package包/类
private void createEnumTypeNameField(final Composite parent) {
final Label label= new Label(parent, SWT.NONE);
label.setText(Messages.ConvertToEnumTypePage_EnumName);
label.setLayoutData(new GridData());
fNameField= new Text(parent, SWT.BORDER);
fNameField.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
handleNameChanged(fNameField.getText());
}
});
fNameField.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
IField[] fields = (IField[]) getConvertToEnumRefactoring().getFieldsToRefactor().toArray(new IField[] {});
List fieldList = new ArrayList(fields.length);
for (int i = 0; i < fields.length; i++) {
IField field = fields[i];
fieldList.add(field.getElementName());
}
String suggestedName = getSuggestedEnumTypeName((String[]) fieldList.toArray(new String[]{}));
fNameField.setText(suggestedName);
}
示例10: handleNameChanged
import org.eclipse.jdt.core.IField; //导入依赖的package包/类
/**
* Handles the name changed event.
*
* @param name
* the name
*/
protected void handleNameChanged(final String name) {
if (name != null) {
String packageName = Util.getPackageName(name);
if ( packageName.isEmpty() && !getConvertToEnumRefactoring().getFieldsToRefactor().isEmpty() ) {
//assign package to be the package of the first constant.
//TODO [rk]: Done just to avoid default package for now.
IField field = (IField) getConvertToEnumRefactoring().getFieldsToRefactor().iterator().next();
IType parent = (IType) field.getParent();
String fullyQualifiedName = parent.getFullyQualifiedName();
packageName = Util.getPackageName(fullyQualifiedName);
}
getConvertToEnumRefactoring().setPackageName(packageName);
String simpleName = Util.getSimpleName(name);
getConvertToEnumRefactoring().setSimpleTypeName(simpleName);
}
checkPageCompletionStatus(true);
}
示例11: FieldDialogImpl
import org.eclipse.jdt.core.IField; //导入依赖的package包/类
public FieldDialogImpl(CommandIdentifier commandIdentifier, Shell parentShell, String dialogTitle, IField[] fields,
LinkedHashSet<StrategyIdentifier> possibleStrategies, boolean disableAppendSuper,
PreferencesManager preferencesManager, IDialogSettings dialogSettings,
LinkedHashMap<String, IJavaElement> insertPositions, DialogStrategyManager dialogStrategyManager) {
super(parentShell);
this.commandIdentifier = commandIdentifier;
this.generalDialogSettings = dialogSettings;
this.dialogStrategyManager = dialogStrategyManager;
setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE);
this.title = dialogTitle;
this.allFields = fields;
this.disableAppendSuper = disableAppendSuper;
this.preferencesManager = preferencesManager;
this.possibleStrategies = possibleStrategies;
this.insertPositions = insertPositions;
this.fieldDialogSettings = initFieldDialogSettings();
initCurrentStrategy();
currentDialogStrategy.configureSpecificDialogSettings(generalDialogSettings);
}
示例12: getDistinctSets
import org.eclipse.jdt.core.IField; //导入依赖的package包/类
public static Collection getDistinctSets(Collection elementSets)
throws JavaModelException {
final Collection ret = new LinkedHashSet(elementSets);
for (final Iterator it = elementSets.iterator(); it.hasNext();) {
final Collection set = (Collection) it.next();
final Collection constValues = new ArrayList();
for (final Iterator jit = set.iterator(); jit.hasNext();) {
final IJavaElement elem = (IJavaElement) jit.next();
if (elem.getElementType() == IJavaElement.FIELD) {
final IField field = (IField) elem;
final Object constValue = field.getConstant();
if (constValue != null)
constValues.add(constValue);
}
}
if (!distinct(constValues))
ret.remove(set);
}
return ret;
}
示例13: validateObjectTree
import org.eclipse.jdt.core.IField; //导入依赖的package包/类
private void validateObjectTree(ExpressionReference e, IncludedObject object) throws JavaModelException, ExpressionLanguageException {
IType type = object.getFieldType();
int currentSegment = 1;
if (type != null) {
while (currentSegment < e.getSegmentCount()) {
String name = e.getSegment(currentSegment++);
IField field = type.getField(name);
if (field == null) {
throw new ExpressionLanguageException(name + " not included in " +
controller.getName(), expression.getLocation());
} else {
type = field.getDeclaringType();
}
}
}
}
示例14: createRenameSupport
import org.eclipse.jdt.core.IField; //导入依赖的package包/类
private static RenameSupport createRenameSupport(IJavaElement element, String newName, int flags)
throws CoreException {
switch (element.getElementType()) {
case IJavaElement.PACKAGE_FRAGMENT:
return RenameSupport.create((IPackageFragment) element, newName, flags);
case IJavaElement.COMPILATION_UNIT:
return RenameSupport.create((ICompilationUnit) element, newName, flags);
case IJavaElement.TYPE:
return RenameSupport.create((IType) element, newName, flags);
case IJavaElement.METHOD:
final IMethod method = (IMethod) element;
if (method.isConstructor())
return createRenameSupport(method.getDeclaringType(), newName, flags);
else return RenameSupport.create((IMethod) element, newName, flags);
case IJavaElement.FIELD:
return RenameSupport.create((IField) element, newName, flags);
case IJavaElement.TYPE_PARAMETER:
return RenameSupport.create((ITypeParameter) element, newName, flags);
case IJavaElement.LOCAL_VARIABLE:
return RenameSupport.create((ILocalVariable) element, newName, flags);
}
return null;
}
示例15: close
import org.eclipse.jdt.core.IField; //导入依赖的package包/类
@Override
public boolean close() {
List<Object> list = Arrays.asList(fieldViewer.getCheckedElements());
selectedFields = list.toArray(new IField[list.size()]);
if (DialogFactoryHelperImpl.FIRST_METHOD_POSITION.equals(currentPosition)
|| DialogFactoryHelperImpl.LAST_METHOD_POSITION.equals(currentPosition)) {
fieldDialogSettings.put(SETTINGS_INSERT_POSITION, currentPosition);
}
if (!disableAppendSuper) {
fieldDialogSettings.put(SETTINGS_APPEND_SUPER, appendSuper);
}
fieldDialogSettings.put(SETTINGS_GENERATE_COMMENT, generateComment);
fieldDialogSettings.put(SETTINGS_USE_GETTERS, useGettersInsteadOfFields);
currentDialogStrategy.callbackBeforeDialogClosing();
currentDialogStrategy.disposeSpecificComponents();
return super.close();
}