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


Java StringLiteral类代码示例

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


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

示例1: createUnobservedInitStmt

import org.eclipse.jdt.core.dom.StringLiteral; //导入依赖的package包/类
@SuppressWarnings("unchecked")
	@Override
	public void createUnobservedInitStmt(CaptureLog log, int logRecNo) 
	{
		PostProcessor.notifyRecentlyProcessedLogRecNo(logRecNo);
		
		// NOTE: PLAIN INIT: has always one non-null param
		// TODO: use primitives
		final int    oid     = log.objectIds.get(logRecNo);
//		final String type    = log.oidClassNames.get(log.oidRecMapping.get(oid));
		final Object value   = log.params.get(logRecNo)[0];
		this.isXStreamNeeded = true;
		
		final VariableDeclarationFragment vd = ast.newVariableDeclarationFragment();
		// handling because there must always be a new instantiation statement for pseudo inits
		this.oidToVarMapping.remove(oid);
		vd.setName(ast.newSimpleName(this.createNewVarName(oid, log.oidClassNames.get(log.oidRecMapping.get(oid)), true)));
		
		final MethodInvocation methodInvocation = ast.newMethodInvocation();
		final Name name = ast.newSimpleName("XSTREAM");
		methodInvocation.setExpression(name);
		methodInvocation.setName(ast.newSimpleName("fromXML")); 
		
		final StringLiteral xmlParam = ast.newStringLiteral();
		xmlParam.setLiteralValue((String) value);
		methodInvocation.arguments().add(xmlParam);
		
//		final CastExpression castExpr = ast.newCastExpression();
//		castExpr.setType(this.createAstType(type, ast));
//		castExpr.setExpression(methodInvocation);
		
//		vd.setInitializer(castExpr);
		vd.setInitializer(methodInvocation);
		
		final VariableDeclarationStatement vs = ast.newVariableDeclarationStatement(vd);
		vs.setType(this.createAstType("Object", ast));
				
		methodBlock.statements().add(vs);
	}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:40,代码来源:JUnitCodeGenerator.java

示例2: createUnobservedInitStmt

import org.eclipse.jdt.core.dom.StringLiteral; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void createUnobservedInitStmt(final int logRecNo, final Block methodBlock, final AST ast)
{
	// NOTE: PLAIN INIT: has always one non-null param
	// TODO: use primitives
	final int    oid     = this.log.objectIds.get(logRecNo);
	final String type    = this.log.oidClassNames.get(this.log.oidRecMapping.get(oid));
	final Object value   = this.log.params.get(logRecNo)[0];
	this.isXStreamNeeded = true;
	
	final VariableDeclarationFragment vd = ast.newVariableDeclarationFragment();
	// handling because there must always be a new instantiation statement for pseudo inits
	this.oidToVarMapping.remove(oid);
	vd.setName(ast.newSimpleName(this.createNewVarName(oid, type)));
	
	final MethodInvocation methodInvocation = ast.newMethodInvocation();
	final Name name = ast.newSimpleName("XSTREAM");
	methodInvocation.setExpression(name);
	methodInvocation.setName(ast.newSimpleName("fromXML")); 
	
	final StringLiteral xmlParam = ast.newStringLiteral();
	xmlParam.setLiteralValue((String) value);
	methodInvocation.arguments().add(xmlParam);
	
	final CastExpression castExpr = ast.newCastExpression();
	castExpr.setType(this.createAstType(type, ast));
	castExpr.setExpression(methodInvocation);
	
	vd.setInitializer(castExpr);
	
	final VariableDeclarationStatement vs = ast.newVariableDeclarationStatement(vd);
	vs.setType(this.createAstType(type, ast));
			
	methodBlock.statements().add(vs);
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:36,代码来源:CodeGenerator.java

示例3: isStringNodeInPatternElement

import org.eclipse.jdt.core.dom.StringLiteral; //导入依赖的package包/类
public static boolean isStringNodeInPatternElement(StringLiteral node) {
	ASTNode parent = node.getParent();
	StructuralPropertyDescriptor locationInParent = node.getLocationInParent();
	if (locationInParent.isChildProperty() && !locationInParent.isChildListProperty()) {
		return false;
	}
	if (parent instanceof MethodInvocation) {
		MethodInvocation parentMethodInvocation = (MethodInvocation) parent;
		if (isPatternPart(parentMethodInvocation)) {
			return true;
		} else if (isStringPattern(parentMethodInvocation)) {
			return true;
		} else {

		}
	} else {
		LOG.fine("not ClassInstanceCreation " + parent.getClass().getName() + " " + parent);
	}
	return false;
}
 
开发者ID:impetuouslab,项目名称:eclipse-filecompletion,代码行数:21,代码来源:FileClassFinder.java

示例4: findPathGeneratorInGraphWalkerAnnotation

import org.eclipse.jdt.core.dom.StringLiteral; //导入依赖的package包/类
/**
 * @param cu
 * @return
 */
public static String findPathGeneratorInGraphWalkerAnnotation(ICompilationUnit cu) {
	CompilationUnit ast = parse(cu);
	Map<String, String> ret = new HashMap<String, String>();
	ast.accept(new ASTVisitor() {
		public boolean visit(MemberValuePair node) {
			String name = node.getName().getFullyQualifiedName();
			if ("value".equals(name) && node.getParent() != null && node.getParent() instanceof NormalAnnotation) {
				IAnnotationBinding annoBinding = ((NormalAnnotation) node.getParent()).resolveAnnotationBinding();
				String qname = annoBinding.getAnnotationType().getQualifiedName();
				if (GraphWalker.class.getName().equals(qname)) {
					StringLiteral sl = (StringLiteral) node.getValue();
					ret.put("ret", sl.getLiteralValue());
				}
			}
			return true;
		}
	});
	return ret.get("ret");
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:24,代码来源:JDTManager.java

示例5: RefinementString

import org.eclipse.jdt.core.dom.StringLiteral; //导入依赖的package包/类
public RefinementString(Expression e) {
    if (knownConstants(e))
        return;

    if ( !(e instanceof StringLiteral)) {
        this.exists = false;
        this.length = 0;
        this.containsPunct = false;
        return;
    }

    String s = ((StringLiteral) e).getLiteralValue();
    this.exists = true;
    this.length = s.length();
    this.containsPunct = hasPunct(s);
}
 
开发者ID:capergroup,项目名称:bayou,代码行数:17,代码来源:RefinementString.java

示例6: setFieldAnnotation

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

示例7: declareOtherDomains

import org.eclipse.jdt.core.dom.StringLiteral; //导入依赖的package包/类
private void declareOtherDomains(ASTRewrite rewrite, ListRewrite listRewrite, TypeDeclaration typeDeclaration) {
	String qualifiedName = typeDeclaration.resolveBinding().getQualifiedName();
	
	OGraphFacade facade = RefinementAnalysis.getFacade();
	RefinementModel refinementModel = facade.getRefinementModel();
	List<IOtherRefinement> otherRefinements = refinementModel.getOtherRefinements();
	for(IOtherRefinement otherRefinement : otherRefinements ) {
		if (otherRefinement instanceof CreateDomain ) {
			CreateDomain createDomain = (CreateDomain)otherRefinement;
			String fullyQualifiedName = createDomain.getSrcIObject().getC().getFullyQualifiedName();
			if (fullyQualifiedName.equals(qualifiedName)) {
				 StringLiteral newStringLiteralPARAM = rewrite.getAST().newStringLiteral();
				 newStringLiteralPARAM.setLiteralValue(createDomain.getDstDomain());
				 listRewrite.insertLast(newStringLiteralPARAM, null);
			}
		}
	}
			
}
 
开发者ID:aroog,项目名称:code,代码行数:20,代码来源:SaveAnnotations.java

示例8: getTypeAnnotationDomainAssumes

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

示例9: getTypeAnnotationParams

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

示例10: createLiceseInLineField

import org.eclipse.jdt.core.dom.StringLiteral; //导入依赖的package包/类
private FieldDeclaration createLiceseInLineField(AST ast) {
	VariableDeclarationFragment vdf = ast.newVariableDeclarationFragment();
	vdf.setName(ast.newSimpleName("COPYRIGHT"));
	StringLiteral sl = ast.newStringLiteral();
	sl.setLiteralValue(license_inline);
	vdf.setInitializer(sl);
	FieldDeclaration fd = ast.newFieldDeclaration(vdf);
	fd.modifiers().addAll(ast.newModifiers(Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL));
	fd.setType(ast.newSimpleType(ast.newSimpleName("String")));
	
	return fd;
}
 
开发者ID:alexgreenbar,项目名称:open_tools,代码行数:13,代码来源:SampleAction.java

示例11: addSuppressArgument

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

示例12: containsAnnotationValue

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

示例13: validateUiHandlerFieldExistenceInUiXml

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

示例14: validateSourceAnnotationValue

import org.eclipse.jdt.core.dom.StringLiteral; //导入依赖的package包/类
private void validateSourceAnnotationValue(StringLiteral literalNode) throws JavaModelException {
  String value = literalNode.getLiteralValue();

  // Interpret the literal path as an absolute path, and then as a path
  // relative to the containing package (indexing both).
  IPath literalPath = new Path(value);
  result.addPossibleResourcePath(literalPath);
  IPath fullResourcePathIfPackageRelative = getPackagePath(literalNode).append(literalPath);
  result.addPossibleResourcePath(fullResourcePathIfPackageRelative);

  // If the @Source path was absolute and we found it, great
  if (ClasspathResourceUtilities.isResourceOnClasspath(javaProject, literalPath)) {
    return;
  }

  if (!ClasspathResourceUtilities.isResourceOnClasspath(javaProject, fullResourcePathIfPackageRelative)) {
    // Didn't work as a relative path either, so now it's an error
    IPath expectedResourcePath = computeMissingResourceExpectedPath(literalPath, fullResourcePathIfPackageRelative);
    ClientBundleProblem problem = ClientBundleProblem.createMissingResourceFile(literalNode,
        literalPath.lastSegment(), expectedResourcePath.removeLastSegments(1));
    result.addProblem(problem);
  }
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:24,代码来源:ClientBundleValidator.java

示例15: validateSourceAnnotationValues

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


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