本文整理汇总了Java中org.eclipse.jdt.core.dom.FieldDeclaration.fragments方法的典型用法代码示例。如果您正苦于以下问题:Java FieldDeclaration.fragments方法的具体用法?Java FieldDeclaration.fragments怎么用?Java FieldDeclaration.fragments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.FieldDeclaration
的用法示例。
在下文中一共展示了FieldDeclaration.fragments方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import org.eclipse.jdt.core.dom.FieldDeclaration; //导入方法依赖的package包/类
@Override
public boolean visit(FieldDeclaration fieldDeclaration) {
Type fieldType = fieldDeclaration.getType();
int fieldModifiers = fieldDeclaration.getModifiers();
Visibility visibility = getVisibility(fieldModifiers);
// boolean isFinal = (fieldModifiers & Modifier.FINAL) != 0;
boolean isStatic = (fieldModifiers & Modifier.STATIC) != 0;
List<VariableDeclarationFragment> fragments = fieldDeclaration.fragments();
for (VariableDeclarationFragment fragment : fragments) {
String fieldName = fragment.getName().getIdentifier();
final SDAttribute attribute = model.createAttribute(fieldName, containerStack.peek());
attribute.setStatic(isStatic);
attribute.setVisibility(visibility);
attribute.setType(AstUtils.normalizeTypeName(fieldType, fragment.getExtraDimensions(), false));
Expression expression = fragment.getInitializer();
if (expression != null) {
//attribute.setAssignment(srbForAttributes.buildSourceRepresentation(fileContent, expression.getStartPosition(), expression.getLength()));
addClientCode(attribute.key().toString(), srbForAttributes.buildPartialSourceRepresentation(fileContent, expression));
}
attribute.setClientCode(srbForAttributes.buildEmptySourceRepresentation());
}
return true;
}
示例2: visit
import org.eclipse.jdt.core.dom.FieldDeclaration; //导入方法依赖的package包/类
@Override
public boolean visit(FieldDeclaration node) {
int modifiers = node.getModifiers();
if (Modifier.isPrivate(modifiers) || Modifier.isProtected(modifiers)) {
List<VariableDeclarationFragment> fragments = node.fragments();
for (VariableDeclarationFragment varDeclFrag : fragments) {
IVariableBinding varBinding = varDeclFrag.resolveBinding();
String enclosingClass = varBinding.getDeclaringClass().getQualifiedName();
if(!varBinding.getType().isPrimitive() && !varBinding.getType().getQualifiedName().equals("java.lang.String")){
final TACVariable fieldVar = new TACVariable(varBinding);
if(!enclosingClass.equals(Config.MAINCLASS)){
context.addEncapsulatedVariable(fieldVar);
}
}
}
}
return super.visit(node);
}
示例3: visit
import org.eclipse.jdt.core.dom.FieldDeclaration; //导入方法依赖的package包/类
@Override
public boolean visit(FieldDeclaration node) {
List fragments = node.fragments();
for(Object o : fragments) {
VariableDeclarationFragment frag = (VariableDeclarationFragment) o;
String varName = frag.getName().getIdentifier();
int line = cunit.getLineNumber(frag.getStartPosition());
ASTNode parent = node.getParent();
Scope scope = new Scope(cunit.getLineNumber(parent.getStartPosition()), getEndLine(parent, cunit));
TypeDeclaration dec = (TypeDeclaration) node.getParent();
String qName = dec.getName().getFullyQualifiedName();
PackageDeclaration packageDec = cunit.getPackage();
if(packageDec != null)
qName = packageDec.getName().getFullyQualifiedName() + "." + qName;
String type = !Modifier.isStatic(node.getModifiers()) ? qName : null;
VariableTags tags = new VariableTags(varName, type, line, scope, true);
variables.add(tags);
}
return false;
}
示例4: visit
import org.eclipse.jdt.core.dom.FieldDeclaration; //导入方法依赖的package包/类
@Override
public boolean visit(TypeDeclaration node) {
System.out.println(node.getParent().getClass());
if(info == null)
info = new ClassInfo(node.resolveBinding().getQualifiedName(), VisibilityInfo.from(node));
for(FieldDeclaration f : node.getFields()) {
if(!Modifier.isStatic(f.getModifiers())) {
for(Object o : f.fragments()) {
VariableDeclarationFragment frag = (VariableDeclarationFragment) o;
info.addField(new FieldInfo(frag.getName().toString()));
}
}
}
return true;
}
示例5: createFieldInfos
import org.eclipse.jdt.core.dom.FieldDeclaration; //导入方法依赖的package包/类
private List<FieldInfo> createFieldInfos(FieldDeclaration node, String belongTo) {
List<FieldInfo> fieldInfos = new ArrayList<>();
Type type = node.getType();
Set<String> types = getTypes(type);
String typeString = type.toString();
String visibility = getVisibility(node);
boolean isStatic = isStatic(node);
boolean isFinal = isFinal(node);
String comment = "";
if (node.getJavadoc() != null)
comment = sourceContent.substring(node.getJavadoc().getStartPosition(), node.getJavadoc().getStartPosition() + node.getJavadoc().getLength());
List<VariableDeclarationFragment> fragments = node.fragments();
for (VariableDeclarationFragment fragment : fragments) {
FieldInfo fieldInfo = new FieldInfo();
fieldInfo.belongTo = belongTo;
fieldInfo.name = fragment.getName().getFullyQualifiedName();
fieldInfo.typeString = typeString;
fieldInfo.types = types;
fieldInfo.visibility = visibility;
fieldInfo.isFinal = isFinal;
fieldInfo.isStatic = isStatic;
fieldInfo.comment = comment;
fieldInfos.add(fieldInfo);
}
return fieldInfos;
}
示例6: getClassAttributes
import org.eclipse.jdt.core.dom.FieldDeclaration; //导入方法依赖的package包/类
/**
* Method to get class attributes and add them in a list.
* @author Mariana Azevedo
* @since 13/07/2014
* @param node
*/
@SuppressWarnings("unchecked")
private void getClassAttributes(CompilationUnit node){
for (Object type : node.types()){
if (type instanceof TypeDeclaration){
FieldDeclaration [] attributes = ((TypeDeclaration) type).getFields();
for (FieldDeclaration attribute: attributes){
List<FieldDeclaration> fragments = attribute.fragments();
Object obj = fragments.get(0);
if (obj instanceof VariableDeclarationFragment){
String str = ((VariableDeclarationFragment) obj).getName().toString();
this.listOfAttributes.add(str);
}
}
}
}
}
示例7: getClassAttributes
import org.eclipse.jdt.core.dom.FieldDeclaration; //导入方法依赖的package包/类
/**
* Method to get all attributes or fields of a class.
* @author Mariana Azevedo
* @since 13/07/2014
* @param node
*/
@SuppressWarnings("unchecked")
private void getClassAttributes(CompilationUnit node){
for (Object type : node.types()){
if (type instanceof TypeDeclaration){
FieldDeclaration [] attributes = ((TypeDeclaration) type).getFields();
for (FieldDeclaration attribute: attributes){
List<FieldDeclaration> fragments = attribute.fragments();
Object obj = fragments.get(0);
if (obj instanceof VariableDeclarationFragment){
String s = ((VariableDeclarationFragment) obj).getName().toString();
this.listOfAttributes.add(s);
}
}
}
}
}
示例8: getEnclosingType
import org.eclipse.jdt.core.dom.FieldDeclaration; //导入方法依赖的package包/类
/**
* @param methodBinding
* @return
*//*
private ast.TypeDeclaration getEnclosingType(IMethodBinding methodBinding) {
ast.TypeDeclaration typeDeclaration = getTypeDeclaration(methodBinding.getDeclaringClass());
return typeDeclaration;
}*/
public static List<ast.FieldDeclaration> getDeclaredFields(
TypeDeclaration td) {
List<ast.FieldDeclaration> fieldList = new ArrayList<ast.FieldDeclaration>();
for(FieldDeclaration fieldDec: td.getFields()){
List<VariableDeclarationFragment> fragments = fieldDec.fragments();
for(VariableDeclarationFragment varDecFrag: fragments){
fieldList.add(getFieldDeclaration(varDecFrag));
}
}
return fieldList;
}
示例9: visit
import org.eclipse.jdt.core.dom.FieldDeclaration; //导入方法依赖的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;
}
示例10: createPrivateUiField
import org.eclipse.jdt.core.dom.FieldDeclaration; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static Set<UiBinderJavaProblem> createPrivateUiField(
FieldDeclaration uiFieldDecl, Modifier privateModifier) {
Set<UiBinderJavaProblem> problems = new HashSet<UiBinderJavaProblem>();
List<VariableDeclarationFragment> varDecls = uiFieldDecl.fragments();
for (VariableDeclarationFragment varDecl : varDecls) {
String fieldName = varDecl.getName().getIdentifier();
UiBinderJavaProblem problem = create(privateModifier,
UiBinderJavaProblemType.PRIVATE_UI_FIELD, new String[] {fieldName},
NO_STRINGS);
if (problem != null) {
problems.add(problem);
}
}
return problems;
}
示例11: addFieldProposal
import org.eclipse.jdt.core.dom.FieldDeclaration; //导入方法依赖的package包/类
private void addFieldProposal(List<ICompletionProposal> proposals,
FieldDeclaration fieldDecl) {
@SuppressWarnings("unchecked")
List<VariableDeclarationFragment> fragments = fieldDecl.fragments();
for (VariableDeclarationFragment fragment : fragments) {
String fieldName = fragment.getName().getIdentifier();
if (fieldName.startsWith(getEnteredText())) {
proposals.add(new ReplacementCompletionProposal(fieldName,
getReplaceOffset(), getReplaceLength(),
ReplacementCompletionProposal.DEFAULT_CURSOR_POSITION, null,
fieldName, XmlContentAssistUtilities.getImageForLocalVariable()));
}
}
}
示例12: validateUiFieldExistenceInUiXml
import org.eclipse.jdt.core.dom.FieldDeclaration; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void validateUiFieldExistenceInUiXml(FieldDeclaration uiFieldDecl) {
List<VariableDeclarationFragment> varDecls = uiFieldDecl.fragments();
for (VariableDeclarationFragment varDecl : varDecls) {
SimpleName fieldNameDecl = varDecl.getName();
validateFieldExistenceInUiXml(
(TypeDeclaration) uiFieldDecl.getParent(), fieldNameDecl,
fieldNameDecl.getIdentifier());
}
}
示例13: initializeDeclaration
import org.eclipse.jdt.core.dom.FieldDeclaration; //导入方法依赖的package包/类
private void initializeDeclaration(TypeDeclaration node) {
FieldDeclaration[] fields= node.getFields();
for (int i= 0; i < fields.length; i++) {
FieldDeclaration fieldDeclaration= fields[i];
List<VariableDeclarationFragment> fragments= fieldDeclaration.fragments();
for (Iterator<VariableDeclarationFragment> iterator= fragments.iterator(); iterator.hasNext();) {
VariableDeclarationFragment vdf= iterator.next();
FieldInfo fieldInfo= getFieldInfo(vdf.getName().getIdentifier());
if (fieldInfo != null) {
Assert.isNotNull(vdf);
fieldInfo.declaration= vdf;
fieldInfo.pi.setOldBinding(vdf.resolveBinding());
}
}
}
}
示例14: parseFieldDeclaration
import org.eclipse.jdt.core.dom.FieldDeclaration; //导入方法依赖的package包/类
/**
* Factory Method for ASTField.
*
* @param node
* FiledDeclaration node of Eclipse AST
*/
public void parseFieldDeclaration(FieldDeclaration node) {
for (Object obj : node.fragments()) {
VariableDeclarationFragment fragment = (VariableDeclarationFragment) obj;
String fieldName = fragment.getName().toString();
int fieldModifier = node.getModifiers();
String fieldVisibility = getVisibility(fieldModifier);
Blob fieldBlob = new Blob(fieldVisibility + "\n", fieldName);
if (fieldMap.containsKey(fieldName)) {
int numConflicted = 0;
for (Blob field : fieldMap.get(fieldName)) {
conflict(field, fieldName, numConflicted++);
}
conflict(fieldBlob, fieldName, numConflicted);
}
fieldMap.put(fieldName, fieldBlob);
}
}
示例15: getFieldDeclaration
import org.eclipse.jdt.core.dom.FieldDeclaration; //导入方法依赖的package包/类
/**
* Returns the <CODE>FieldDeclaration</CODE> for the specified field name.
* The field has to be declared in the specified
* <CODE>TypeDeclaration</CODE>.
*
* @param type
* The <CODE>TypeDeclaration</CODE>, where the
* <CODE>FieldDeclaration</CODE> is declared in.
* @param fieldName
* The simple field name to search for.
* @return the <CODE>FieldDeclaration</CODE> found in the specified
* <CODE>TypeDeclaration</CODE>.
* @throws FieldDeclarationNotFoundException
* if no matching <CODE>FieldDeclaration</CODE> was found.
*/
public static FieldDeclaration getFieldDeclaration(TypeDeclaration type, String fieldName)
throws FieldDeclarationNotFoundException {
checkForNull(type, "type declaration");
checkForNull(fieldName, "field name");
for (FieldDeclaration field : type.getFields()) {
for (Object fragObj : field.fragments()) {
VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragObj;
if (fieldName.equals(fragment.getName().getIdentifier())) {
return field;
}
}
}
throw new FieldDeclarationNotFoundException(type, fieldName);
}