当前位置: 首页>>代码示例>>Java>>正文


Java SingleMemberAnnotation类代码示例

本文整理汇总了Java中org.eclipse.jdt.core.dom.SingleMemberAnnotation的典型用法代码示例。如果您正苦于以下问题:Java SingleMemberAnnotation类的具体用法?Java SingleMemberAnnotation怎么用?Java SingleMemberAnnotation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SingleMemberAnnotation类属于org.eclipse.jdt.core.dom包,在下文中一共展示了SingleMemberAnnotation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setFieldAnnotation

import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入依赖的package包/类
private void setFieldAnnotation(ASTRewrite rewrite, FieldDeclaration fieldDeclaration, String annotation) {
	SingleMemberAnnotation newFieldAnnotation = fieldDeclaration.getAST().newSingleMemberAnnotation();
	newFieldAnnotation.setTypeName(rewrite.getAST().newSimpleName("Domain"));
	StringLiteral newStringLiteral = rewrite.getAST().newStringLiteral();
	newStringLiteral.setLiteralValue(annotation);
	newFieldAnnotation.setValue(newStringLiteral);
	ASTNode modifier = getModifier(fieldDeclaration.modifiers());
	if (modifier != null) {
		ListRewrite paramRewrite = rewrite.getListRewrite(fieldDeclaration, FieldDeclaration.MODIFIERS2_PROPERTY);
		paramRewrite.insertAfter(newFieldAnnotation, modifier, null);
	}
	else {
		ListRewrite fieldRewrite = rewrite.getListRewrite(fieldDeclaration, FieldDeclaration.MODIFIERS2_PROPERTY);
		fieldRewrite.insertFirst(newFieldAnnotation, null);
	}

}
 
开发者ID:aroog,项目名称:code,代码行数:18,代码来源:RemoveAnnotations.java

示例2: getAnnotation

import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入依赖的package包/类
private ASTNode getAnnotation(List paramModifiers, String annotation) {
	ASTNode found = null;
	for (Iterator itParamModifiers = paramModifiers.iterator(); itParamModifiers.hasNext();) {
		IExtendedModifier o = (IExtendedModifier) itParamModifiers.next();
		if (o instanceof SingleMemberAnnotation) {
			SingleMemberAnnotation annot = (SingleMemberAnnotation) o;

			String name = annot.getTypeName().toString();
			if (name.compareTo(annotation) == 0) {
				found = annot;
				break;
			}
		}
	}
	return found;
}
 
开发者ID:aroog,项目名称:code,代码行数:17,代码来源:RemoveAnnotations.java

示例3: setTypeAnnotationDomains

import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入依赖的package包/类
private void setTypeAnnotationDomains(ASTRewrite rewrite, TypeDeclaration typeDeclaration, String annotation,
        String domainName, ASTNode after) {

	SingleMemberAnnotation newParamAnnotation = getTypeAnnotationDomain(rewrite,
	        typeDeclaration,
	        annotation,
	        domainName);

	ListRewrite paramRewrite = rewrite.getListRewrite(typeDeclaration, TypeDeclaration.MODIFIERS2_PROPERTY);
	if (after == null) {
		paramRewrite.insertFirst(newParamAnnotation, null);
	}
	else {
		paramRewrite.insertAfter(newParamAnnotation, after, null);
	}
}
 
开发者ID:aroog,项目名称:code,代码行数:17,代码来源:SaveAnnotations.java

示例4: getTypeAnnotationDomainAssumes

import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入依赖的package包/类
private SingleMemberAnnotation getTypeAnnotationDomainAssumes(ASTRewrite rewrite, TypeDeclaration typeDeclaration, String annotation, String domainName) {
   ArrayInitializer initializer = rewrite.getAST().newArrayInitializer();

if (domainName != null) {
	ListRewrite listRewrite = rewrite.getListRewrite(initializer, ArrayInitializer.EXPRESSIONS_PROPERTY);
	
	StringLiteral newStringLiteral = rewrite.getAST().newStringLiteral();
	newStringLiteral.setLiteralValue(domainName);
	listRewrite.insertFirst(newStringLiteral, null);
	
	declareOtherDomains(rewrite, listRewrite, typeDeclaration);
}

SingleMemberAnnotation newParamAnnotation = typeDeclaration.getAST().newSingleMemberAnnotation();
newParamAnnotation.setTypeName(rewrite.getAST().newSimpleName(annotation));
newParamAnnotation.setValue(initializer);
   return newParamAnnotation;
  }
 
开发者ID:aroog,项目名称:code,代码行数:19,代码来源:SaveAnnotations.java

示例5: getTypeAnnotationParams

import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入依赖的package包/类
private SingleMemberAnnotation getTypeAnnotationParams(ASTRewrite rewrite, TypeDeclaration typeDeclaration,
          String annotation) {
   ArrayInitializer initializer = rewrite.getAST().newArrayInitializer();

if (!typeDeclaration.resolveBinding().getQualifiedName().equals(Config.MAINCLASS)) {
	StringLiteral newStringLiteral = rewrite.getAST().newStringLiteral();
	newStringLiteral.setLiteralValue("p");

	ListRewrite listRewrite = rewrite.getListRewrite(initializer, ArrayInitializer.EXPRESSIONS_PROPERTY);
	listRewrite.insertFirst(newStringLiteral, null);
}
SingleMemberAnnotation newParamAnnotation = typeDeclaration.getAST().newSingleMemberAnnotation();
newParamAnnotation.setTypeName(rewrite.getAST().newSimpleName(annotation));
newParamAnnotation.setValue(initializer);
   return newParamAnnotation;
  }
 
开发者ID:aroog,项目名称:code,代码行数:17,代码来源:SaveAnnotations.java

示例6: findExistingAnnotation

import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入依赖的package包/类
private static Annotation findExistingAnnotation(List<? extends ASTNode> modifiers) {
  for (int i = 0, len = modifiers.size(); i < len; i++) {
    Object curr = modifiers.get(i);
    if (curr instanceof NormalAnnotation || curr instanceof SingleMemberAnnotation) {
      Annotation annotation = (Annotation) curr;
      ITypeBinding typeBinding = annotation.resolveTypeBinding();
      if (typeBinding != null) {
        if ("java.lang.SuppressWarnings"
            .equals(typeBinding.getQualifiedName())) { // $NON-NLS-1$
          return annotation;
        }
      } else {
        String fullyQualifiedName = annotation.getTypeName().getFullyQualifiedName();
        if ("SuppressWarnings".equals(fullyQualifiedName)
            || "java.lang.SuppressWarnings"
                .equals(fullyQualifiedName)) { // $NON-NLS-1$ //$NON-NLS-2$
          return annotation;
        }
      }
    }
  }
  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:SuppressWarningsSubProcessor.java

示例7: validateUiHandlerFieldExistenceInUiXml

import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void validateUiHandlerFieldExistenceInUiXml(
    MethodDeclaration uiHandlerDecl) {
  Annotation annotation = JavaASTUtils.findAnnotation(uiHandlerDecl,
      UiBinderConstants.UI_HANDLER_TYPE_NAME);

  if (annotation instanceof SingleMemberAnnotation) {
    SingleMemberAnnotation uiHandlerAnnotation = (SingleMemberAnnotation) annotation;
    Expression exp = uiHandlerAnnotation.getValue();
    if (exp instanceof StringLiteral) {
      validateFieldExistenceInUiXml(
          (TypeDeclaration) uiHandlerDecl.getParent(), exp,
          ((StringLiteral) exp).getLiteralValue());
    } else if (exp instanceof ArrayInitializer) {
      for (Expression element : (List<Expression>) ((ArrayInitializer) exp).expressions()) {
        if (element instanceof StringLiteral) {
          validateFieldExistenceInUiXml(
              (TypeDeclaration) uiHandlerDecl.getParent(), element,
              ((StringLiteral) element).getLiteralValue());
        }
      }
    }
  }
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:25,代码来源:UiBinderJavaValidator.java

示例8: getExplicitMultiplicity

import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入依赖的package包/类
private static Integer getExplicitMultiplicity(TypeDeclaration typeDeclaration, String annotationName) {
	for (Object modifier : typeDeclaration.modifiers()) {
		if (modifier instanceof SingleMemberAnnotation) {
			SingleMemberAnnotation annotation = (SingleMemberAnnotation) modifier;
			if (annotation.getTypeName().toString().equals(annotationName)) {
				Expression value = annotation.getValue();
				if (value instanceof NumberLiteral) {
					NumberLiteral num = (NumberLiteral) value;
					try {
						return new Integer(Integer.parseInt(num.getToken()));
					} catch (NumberFormatException e) {
						// Just let it fall through to returning 'null'
						// below.
					}
				}
			}
		}
	}
	return null;
}
 
开发者ID:ELTE-Soft,项目名称:txtUML,代码行数:21,代码来源:MultiplicityProvider.java

示例9: findExistingAnnotation

import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入依赖的package包/类
private static Annotation findExistingAnnotation(List<? extends ASTNode> modifiers) {
	for (int i= 0, len= modifiers.size(); i < len; i++) {
		Object curr= modifiers.get(i);
		if (curr instanceof NormalAnnotation || curr instanceof SingleMemberAnnotation) {
			Annotation annotation= (Annotation) curr;
			ITypeBinding typeBinding= annotation.resolveTypeBinding();
			if (typeBinding != null) {
				if ("java.lang.SuppressWarnings".equals(typeBinding.getQualifiedName())) { //$NON-NLS-1$
					return annotation;
				}
			} else {
				String fullyQualifiedName= annotation.getTypeName().getFullyQualifiedName();
				if ("SuppressWarnings".equals(fullyQualifiedName) || "java.lang.SuppressWarnings".equals(fullyQualifiedName)) { //$NON-NLS-1$ //$NON-NLS-2$
					return annotation;
				}
			}
		}
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:SuppressWarningsSubProcessor.java

示例10: annotations

import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入依赖的package包/类
/**
 * Returns the annotations for a given <code>modifierList</code>.
 * 
 * @param modifierList the modifier list to be processed
 * @return An ArraySet with all annotations
 */
@OperationMeta(returnGenerics = JavaAnnotation.class)
public Set<JavaAnnotation> annotations(List<IExtendedModifier> modifierList) {
    List<JavaAnnotation> list = new ArrayList<JavaAnnotation>();
    for (Object modifier : modifierList) {
        if (modifier instanceof org.eclipse.jdt.core.dom.Annotation) {
            org.eclipse.jdt.core.dom.Annotation annot = (org.eclipse.jdt.core.dom.Annotation) modifier;
            // Get annotation name and value
            Map<String, String> fields = new HashMap<String, String>();
            // possibly the unqualified name as not resolved unless not given as qualified name!
            String name = annot.getTypeName().getFullyQualifiedName(); 
            if (annot instanceof SingleMemberAnnotation) {
                fields.put(JavaAnnotation.DEFAULT_FIELD, 
                    toString(((SingleMemberAnnotation) modifier).getValue()));
            } else if (annot instanceof NormalAnnotation) {
                @SuppressWarnings("unchecked")
                List<MemberValuePair> values = ((NormalAnnotation) annot).values();
                for (MemberValuePair pair : values) {
                    fields.put(pair.getName().getIdentifier(), toString(pair.getValue()));
                }
            }
            list.add(new JavaAnnotation(name, fields, this));
        }
    }
    return new ArraySet<JavaAnnotation>(list.toArray(new JavaAnnotation[list.size()]), JavaAnnotation.class);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:32,代码来源:JavaParentFragmentArtifact.java

示例11: createGeneratedAnnotation

import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入依赖的package包/类
private SingleMemberAnnotation createGeneratedAnnotation(AST ast) {
    SingleMemberAnnotation generatedAnnotation = ast.newSingleMemberAnnotation();
    generatedAnnotation.setTypeName(ast.newSimpleName("Generated"));
    StringLiteral annotationValue = ast.newStringLiteral();
    annotationValue.setLiteralValue(StaticPreferences.PLUGIN_GENERATED_ANNOTATION_NAME);
    generatedAnnotation.setValue(annotationValue);
    return generatedAnnotation;
}
 
开发者ID:helospark,项目名称:SparkBuilderGenerator,代码行数:9,代码来源:GeneratedAnnotationPopulator.java

示例12: test

import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入依赖的package包/类
@Override
public boolean test(BodyDeclaration bodyDeclaration) {
    return ((List<IExtendedModifier>) bodyDeclaration.modifiers())
            .stream()
            .filter(modifier -> modifier instanceof SingleMemberAnnotation)
            .map(modifier -> (SingleMemberAnnotation) modifier)
            .filter(modifier -> isGeneratedAnnotation(modifier))
            .filter(modifier -> modifier.getValue() instanceof StringLiteral)
            .filter(annotation -> ((StringLiteral) annotation.getValue()).getLiteralValue().equals(PLUGIN_GENERATED_ANNOTATION_NAME))
            .findFirst()
            .isPresent();
}
 
开发者ID:helospark,项目名称:SparkBuilderGenerator,代码行数:13,代码来源:GeneratedAnnotationPredicate.java

示例13: endVisit

import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入依赖的package包/类
@Override
public void endVisit(SingleMemberAnnotation node) {
	if (skipNode(node)) {
		return;
	}
	assignFlowInfo(node, node.getValue());
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:8,代码来源:FlowAnalyzer.java

示例14: traverseMethodParams

import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入依赖的package包/类
private void traverseMethodParams(MethodDeclaration methodDeclaration) throws IOException {
	List parameters = methodDeclaration.parameters();
	for (Iterator itParams = parameters.iterator(); itParams.hasNext();) {
		SingleVariableDeclaration param = (SingleVariableDeclaration) itParams.next();

		ITypeBinding type = param.resolveBinding().getType();
		if (hasAnnotation(param.modifiers()) && !type.isPrimitive()) {
			SingleMemberAnnotation annotation = getAnnotation(param.modifiers());
			Expression value = annotation.getValue();
			if (value instanceof StringLiteral) { //@Domain("D")
				StringLiteral annotValue = (StringLiteral)value;
				String parserInput = annotValue.getLiteralValue();
				AnnotationInfo annotInfo = AnnotationInfo.parseAnnotation(parserInput); 
				DomainParams annot = annotInfo.getAnnotation();	
			boolean isDom = isDomain(methodDeclaration.resolveBinding().getDeclaringClass(), annot);
			boolean isDomPars = isDomainParams(methodDeclaration.resolveBinding().getDeclaringClass(), annot);
			
			ObjectMetricItem archMetricItem = new ObjectMetricItem(param.resolveBinding().getKey(),
				        param.getName().getFullyQualifiedName(),
				        param.getType().resolveBinding().getQualifiedName(),
				        parserInput,
				        methodDeclaration.resolveBinding().getDeclaringClass().getQualifiedName(),
				        param.toString(),
				        Modifier.isStatic(param.getModifiers()),
				        "MethodParams",
				        param.resolveBinding().getType().isArray(),
				        param.resolveBinding().getType().isEnum(),
				        param.resolveBinding().getType().isParameterizedType(),
				        isDom,
				        isDomPars,
				        annot.isObjectPublicDomain());
			if (!objectsHashtable.containsKey(archMetricItem.toString())) {
				objectsHashtable.put(archMetricItem.toString(), archMetricItem);
				}
				// TODO: src.triplets for Method Params
			}
		}
	}
}
 
开发者ID:aroog,项目名称:code,代码行数:40,代码来源:AnnotatMetrics.java

示例15: hasAnnotation

import org.eclipse.jdt.core.dom.SingleMemberAnnotation; //导入依赖的package包/类
private boolean hasAnnotation(List<IExtendedModifier> paramModifiers) {
	boolean found = false;
	for (Iterator<IExtendedModifier> itParamModifiers = paramModifiers.iterator(); itParamModifiers.hasNext();) {
		Object o = itParamModifiers.next();
		if (o instanceof SingleMemberAnnotation) {
			SingleMemberAnnotation annot = (SingleMemberAnnotation) o;
			String name = annot.getTypeName().toString();
			if (name.compareTo("Domain") == 0) {
				found = true;
			}
		}
	}
	return found;
}
 
开发者ID:aroog,项目名称:code,代码行数:15,代码来源:AnnotatMetrics.java


注:本文中的org.eclipse.jdt.core.dom.SingleMemberAnnotation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。