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


Java ArrayInitializer类代码示例

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


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

示例1: getTypeAnnotationDomainAssumes

import org.eclipse.jdt.core.dom.ArrayInitializer; //导入依赖的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

示例2: getTypeAnnotationParams

import org.eclipse.jdt.core.dom.ArrayInitializer; //导入依赖的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

示例3: create

import org.eclipse.jdt.core.dom.ArrayInitializer; //导入依赖的package包/类
@Override
public ITypeConstraint[] create(ArrayInitializer arrayInitializer) {
  ITypeBinding arrayBinding = arrayInitializer.resolveTypeBinding();
  Assert.isTrue(arrayBinding.isArray());
  List<Expression> expressions = arrayInitializer.expressions();
  List<ITypeConstraint> constraints = new ArrayList<ITypeConstraint>();
  Type type = getTypeParent(arrayInitializer);
  ConstraintVariable typeVariable = fConstraintVariableFactory.makeTypeVariable(type);
  for (int i = 0; i < expressions.size(); i++) {
    Expression each = expressions.get(i);
    ITypeConstraint[] c =
        fTypeConstraintFactory.createSubtypeConstraint(
            fConstraintVariableFactory.makeExpressionOrTypeVariable(each, getContext()),
            typeVariable);
    constraints.addAll(Arrays.asList(c));
  }
  return constraints.toArray(new ITypeConstraint[constraints.size()]);
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:FullConstraintCreator.java

示例4: addSuppressArgument

import org.eclipse.jdt.core.dom.ArrayInitializer; //导入依赖的package包/类
private static boolean addSuppressArgument(
    ASTRewrite rewrite, Expression value, StringLiteral newStringLiteral) {
  if (value instanceof ArrayInitializer) {
    ListRewrite listRewrite =
        rewrite.getListRewrite(value, ArrayInitializer.EXPRESSIONS_PROPERTY);
    listRewrite.insertLast(newStringLiteral, null);
  } else if (value instanceof StringLiteral) {
    ArrayInitializer newArr = rewrite.getAST().newArrayInitializer();
    newArr.expressions().add(rewrite.createMoveTarget(value));
    newArr.expressions().add(newStringLiteral);
    rewrite.replace(value, newArr, null);
  } else {
    return false;
  }
  return true;
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:SuppressWarningsSubProcessor.java

示例5: newDefaultExpression

import org.eclipse.jdt.core.dom.ArrayInitializer; //导入依赖的package包/类
private Expression newDefaultExpression(
    AST ast, ITypeBinding type, ImportRewriteContext context) {
  if (type.isPrimitive()) {
    String name = type.getName();
    if ("boolean".equals(name)) { // $NON-NLS-1$
      return ast.newBooleanLiteral(false);
    } else {
      return ast.newNumberLiteral("0"); // $NON-NLS-1$
    }
  }
  if (type == ast.resolveWellKnownType("java.lang.String")) { // $NON-NLS-1$
    return ast.newStringLiteral();
  }
  if (type.isArray()) {
    ArrayInitializer initializer = ast.newArrayInitializer();
    initializer.expressions().add(newDefaultExpression(ast, type.getElementType(), context));
    return initializer;
  }
  if (type.isAnnotation()) {
    MarkerAnnotation annotation = ast.newMarkerAnnotation();
    annotation.setTypeName(ast.newName(getImportRewrite().addImport(type, context)));
    return annotation;
  }
  return ast.newNullLiteral();
}
 
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:MissingAnnotationAttributesProposal.java

示例6: containsAnnotationValue

import org.eclipse.jdt.core.dom.ArrayInitializer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static boolean containsAnnotationValue(Expression annotationValue,
    String value) {
  if (annotationValue.getNodeType() == ASTNode.STRING_LITERAL) {
    String valueString = ((StringLiteral) annotationValue).getLiteralValue();
    return value.equals(valueString);
  } else if (annotationValue.getNodeType() == ASTNode.ARRAY_INITIALIZER) {
    // If the annotation value is actually an array, check each element
    List<Expression> warningTypes = ((ArrayInitializer) annotationValue).expressions();
    for (Expression warningType : warningTypes) {
      if (containsAnnotationValue(warningType, value)) {
        return true;
      }
    }
  }

  return false;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:19,代码来源:JavaASTUtils.java

示例7: validateUiHandlerFieldExistenceInUiXml

import org.eclipse.jdt.core.dom.ArrayInitializer; //导入依赖的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: validateSourceAnnotationValues

import org.eclipse.jdt.core.dom.ArrayInitializer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void validateSourceAnnotationValues(Annotation annotation) throws JavaModelException {
  Expression exp = JavaASTUtils.getAnnotationValue(annotation);
  if (exp == null) {
    return;
  }

  // There will usually just be one string value
  if (exp instanceof StringLiteral) {
    validateSourceAnnotationValue((StringLiteral) exp);
  }

  // But there could be multiple values; if so, check each one.
  if (exp instanceof ArrayInitializer) {
    ArrayInitializer array = (ArrayInitializer) exp;

    for (Expression item : (List<Expression>) array.expressions()) {
      if (item instanceof StringLiteral) {
        validateSourceAnnotationValue((StringLiteral) item);
      }
    }
  }
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:24,代码来源:ClientBundleValidator.java

示例9: checkExpression

import org.eclipse.jdt.core.dom.ArrayInitializer; //导入依赖的package包/类
private RefactoringStatus checkExpression() throws JavaModelException {
	Expression selectedExpression= getSelectedExpression().getAssociatedExpression();
	if (selectedExpression != null) {
		final ASTNode parent= selectedExpression.getParent();
		if (selectedExpression instanceof NullLiteral) {
			return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_null_literals);
		} else if (selectedExpression instanceof ArrayInitializer) {
			return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_array_initializer);
		} else if (selectedExpression instanceof Assignment) {
			if (parent instanceof Expression && !(parent instanceof ParenthesizedExpression))
				return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_assignment);
			else
				return null;
		} else if (selectedExpression instanceof SimpleName) {
			if ((((SimpleName) selectedExpression)).isDeclaration())
				return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_names_in_declarations);
			if (parent instanceof QualifiedName && selectedExpression.getLocationInParent() == QualifiedName.NAME_PROPERTY || parent instanceof FieldAccess && selectedExpression.getLocationInParent() == FieldAccess.NAME_PROPERTY)
				return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_select_expression);
		} else if (selectedExpression instanceof VariableDeclarationExpression && parent instanceof TryStatement) {
			return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractTempRefactoring_resource_in_try_with_resources);
		}
	}

	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:ExtractTempRefactoring.java

示例10: create

import org.eclipse.jdt.core.dom.ArrayInitializer; //导入依赖的package包/类
@Override
public ITypeConstraint[] create(ArrayInitializer arrayInitializer){
	ITypeBinding arrayBinding= arrayInitializer.resolveTypeBinding();
	Assert.isTrue(arrayBinding.isArray());
	List<Expression> expressions= arrayInitializer.expressions();
	List<ITypeConstraint> constraints= new ArrayList<ITypeConstraint>();
	Type type= getTypeParent(arrayInitializer);
	ConstraintVariable typeVariable= fConstraintVariableFactory.makeTypeVariable(type);
	for (int i= 0; i < expressions.size(); i++) {
		Expression each= expressions.get(i);
		ITypeConstraint[] c= fTypeConstraintFactory.createSubtypeConstraint(
				fConstraintVariableFactory.makeExpressionOrTypeVariable(each, getContext()),
				typeVariable);
		constraints.addAll(Arrays.asList(c));
	}
	return constraints.toArray(new ITypeConstraint[constraints.size()]);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:FullConstraintCreator.java

示例11: complete

import org.eclipse.jdt.core.dom.ArrayInitializer; //导入依赖的package包/类
@Override
protected void complete() throws CoreException {
	super.complete();
	ReturnStatement rStatement= fAst.newReturnStatement();
	String formatClass;
	if (getContext().is50orHigher())
		formatClass= "java.lang.String"; //$NON-NLS-1$
	else
		formatClass= "java.text.MessageFormat"; //$NON-NLS-1$
	MethodInvocation formatInvocation= createMethodInvocation(addImport(formatClass), "format", null); //$NON-NLS-1$ 
	StringLiteral literal= fAst.newStringLiteral();
	literal.setLiteralValue(buffer.toString());
	formatInvocation.arguments().add(literal);
	if (getContext().is50orHigher()) {
		formatInvocation.arguments().addAll(arguments);
	} else {
		ArrayCreation arrayCreation= fAst.newArrayCreation();
		arrayCreation.setType(fAst.newArrayType(fAst.newSimpleType(addImport("java.lang.Object")))); //$NON-NLS-1$
		ArrayInitializer initializer= fAst.newArrayInitializer();
		arrayCreation.setInitializer(initializer);
		initializer.expressions().addAll(arguments);
		formatInvocation.arguments().add(arrayCreation);
	}
	rStatement.setExpression(formatInvocation);
	toStringMethod.getBody().statements().add(rStatement);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:StringFormatGenerator.java

示例12: newDefaultExpression

import org.eclipse.jdt.core.dom.ArrayInitializer; //导入依赖的package包/类
private Expression newDefaultExpression(AST ast, ITypeBinding type, ImportRewriteContext context) {
	if (type.isPrimitive()) {
		String name= type.getName();
		if ("boolean".equals(name)) { //$NON-NLS-1$
			return ast.newBooleanLiteral(false);
		} else {
			return ast.newNumberLiteral("0"); //$NON-NLS-1$
		}
	}
	if (type == ast.resolveWellKnownType("java.lang.String")) { //$NON-NLS-1$
		return ast.newStringLiteral();
	}
	if (type.isArray()) {
		ArrayInitializer initializer= ast.newArrayInitializer();
		initializer.expressions().add(newDefaultExpression(ast, type.getElementType(), context));
		return initializer;
	}
	if (type.isAnnotation()) {
		MarkerAnnotation annotation= ast.newMarkerAnnotation();
		annotation.setTypeName(ast.newName(getImportRewrite().addImport(type, context)));
		return annotation;
	}
	return ast.newNullLiteral();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:MissingAnnotationAttributesProposal.java

示例13: expressionAt

import org.eclipse.jdt.core.dom.ArrayInitializer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Expression expressionAt(Expression value, int offset)
{
	if (value == null)
		return null;

	if (value.getNodeType() == Expression.ARRAY_INITIALIZER)
	{
		ArrayInitializer arrayInitializer = (ArrayInitializer)value;
		for (Expression expression : (List<Expression>)arrayInitializer.expressions())
		{
			if (isInRange(expression, offset))
			{
				return expression;
			}
		}
	}
	else if (value.getNodeType() == Expression.STRING_LITERAL)
	{
		return value;
	}
	return null;
}
 
开发者ID:mybatis,项目名称:mybatipse,代码行数:24,代码来源:JavaHyperlinkDetector.java

示例14: stringAt

import org.eclipse.jdt.core.dom.ArrayInitializer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private String stringAt(Expression value, int offset)
{
	if (value == null)
		return null;

	if (value.getNodeType() == Expression.ARRAY_INITIALIZER)
	{
		ArrayInitializer arrayInitializer = (ArrayInitializer)value;
		for (Expression expression : (List<Expression>)arrayInitializer.expressions())
		{
			if (isInRange(expression, offset))
			{
				return (String)expression.resolveConstantExpressionValue();
			}
		}
	}
	else if (value.getNodeType() == Expression.STRING_LITERAL)
	{
		return (String)value.resolveConstantExpressionValue();
	}
	return null;
}
 
开发者ID:mybatis,项目名称:mybatipse,代码行数:24,代码来源:JavaElementRenameHandler.java

示例15: getTargetTypeForArrayInitializer

import org.eclipse.jdt.core.dom.ArrayInitializer; //导入依赖的package包/类
private static ITypeBinding getTargetTypeForArrayInitializer(ArrayInitializer arrayInitializer) {
	ASTNode initializerParent= arrayInitializer.getParent();
	while (initializerParent instanceof ArrayInitializer) {
		initializerParent= initializerParent.getParent();
	}
	if (initializerParent instanceof ArrayCreation) {
		return ((ArrayCreation) initializerParent).getType().getElementType().resolveBinding();
	} else if (initializerParent instanceof VariableDeclaration) {
		ITypeBinding typeBinding= ((VariableDeclaration) initializerParent).getName().resolveTypeBinding();
		if (typeBinding != null) {
			return typeBinding.getElementType();
		}
	}
	return null;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:16,代码来源:ASTNodes.java


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