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


Java Comment类代码示例

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


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

示例1: parseAndFillModel

import org.eclipse.jdt.core.dom.Comment; //导入依赖的package包/类
/**
 * Parse the routeFile given while building the instance and fill the model.
 * @param model The EIP Model to fill with parsed elements from routeFile.
 * @throws InvalidArgumentException if given file is not a valid Spring integration file
 */
public void parseAndFillModel(EIPModel model) throws Exception {
   // Read source content.
   routeSource = parseRouteClass();
   
   // Parse and get the compilation unit.
   ASTParser parser = ASTParser.newParser(AST.JLS8);
   parser.setKind(ASTParser.K_COMPILATION_UNIT);
   parser.setSource(routeSource.toCharArray());
   parser.setResolveBindings(false);
   routeCU = (CompilationUnit) parser.createAST(null);
   
   // Visit and build a comment map before parsing.
   for (Object comment : routeCU.getCommentList()) {
      ((Comment) comment).accept(this);
   }
   
   // Initialize and build a route.
   route = EipFactory.eINSTANCE.createRoute();
   model.getOwnedRoutes().add(route);
   
   // 
   routeCU.accept(this);
}
 
开发者ID:lbroudoux,项目名称:eip-designer,代码行数:29,代码来源:CamelJavaFileParser.java

示例2: visit

import org.eclipse.jdt.core.dom.Comment; //导入依赖的package包/类
@Override
public boolean visit(CompilationUnit node) {
	//System.out.println("Found: " + node.getClass());
	// TODO Non-javadoc comments.
	// It looks like the way to do this is add a doComments() method
	// and call it before and after every AST node. Not ideal, but
	// it would work. Can probably use pre/postVisit methods for this
	// purpose
	
	for (Object o : node.getCommentList()) {
		if (!(o instanceof Javadoc)) {
			comments.add((Comment)o);
		}
	}
	/*List l = node.getCommentList();
	for (Object o : l) {
		Comment c = (Comment)o;
		println("COMMENT");
		println(c.toString());
		println("----");
		println(c.getAlternateRoot().getClass().toString());
		println("/COMMENT");
	}*/
	return super.visit(node);
}
 
开发者ID:mrmonday,项目名称:j2d,代码行数:26,代码来源:J2dVisitor.java

示例3: doComments

import org.eclipse.jdt.core.dom.Comment; //导入依赖的package包/类
private void doComments(ASTNode node, boolean post) {
	Comment c = comments.peek();

	while (c != null && c.getStartPosition() > endOfLastNode) {
		int startOfNextNode = post ? siblingOrParentPosition(node) 
				 				   : node.getStartPosition();

		if (c.getStartPosition() + c.getLength() < startOfNextNode) {
			comments.remove().accept(this);
			c = comments.peek();
		} else {
			break;
		}
	}
	endOfLastNode = node.getStartPosition() + node.getLength();
}
 
开发者ID:mrmonday,项目名称:j2d,代码行数:17,代码来源:J2dVisitor.java

示例4: run

import org.eclipse.jdt.core.dom.Comment; //导入依赖的package包/类
public void run() {
	parser.parse(new TagVisitor());
	CommentVisitor commentVisitor = new CommentVisitor();
	for (Comment comment : (List<Comment>) cunit.getCommentList())
		comment.accept(commentVisitor);

	Collections.sort(variables);
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:9,代码来源:TagParser.java

示例5: visit

import org.eclipse.jdt.core.dom.Comment; //导入依赖的package包/类
/**
 * @see ASTVisitor#visit(CompilationUnit)
 */
@SuppressWarnings("unchecked")
@Override
public boolean visit(CompilationUnit unit) {
	List<Comment> commentList = unit.getCommentList();
	for (Comment comment : commentList) {
		comment.delete();
	}
	this.numberOfLinesOfCode = (double) unit.toString().split("\n").length;
	return false;
}
 
开发者ID:mariazevedo88,项目名称:o3smeasures-tool,代码行数:14,代码来源:LinesOfCodeVisitor.java

示例6: addCopyrightsHeader

import org.eclipse.jdt.core.dom.Comment; //导入依赖的package包/类
/**
 * Adds copyright header to the compilation unit
 *
 * @param compilationUnit
 *            compilation unit affected
 * @return compilation unit change
 */
public CompilationUnitChange addCopyrightsHeader(final CompilationUnit compilationUnit) {
	final ICompilationUnit unit = (ICompilationUnit) compilationUnit.getJavaElement();
	change = new CompilationUnitChange(ADD_COPYRIGHT, unit);
	rewriter = ASTRewrite.create(compilationUnit.getAST());
	final ListRewrite listRewrite = rewriter.getListRewrite(compilationUnit.getPackage(),
			PackageDeclaration.ANNOTATIONS_PROPERTY);
	final Comment placeHolder = (Comment) rewriter.createStringPlaceholder(getCopyrightText() + NEW_LINE_SEPARATOR,
			ASTNode.BLOCK_COMMENT);
	listRewrite.insertFirst(placeHolder, null);
	rewriteCompilationUnit(unit, getNewUnitSource(unit, null));
	return change;
}
 
开发者ID:SAP,项目名称:hybris-commerce-eclipse-plugin,代码行数:20,代码来源:CopyrightManager.java

示例7: replaceCopyrightsHeader

import org.eclipse.jdt.core.dom.Comment; //导入依赖的package包/类
/**
 * Replaces copyright header to the compilation unit
 *
 * @param compilationUnit
 *            compilation unit affected
 * @return compilation unit change
 */
public CompilationUnitChange replaceCopyrightsHeader(final CompilationUnit compilationUnit) {
	final ICompilationUnit unit = (ICompilationUnit) compilationUnit.getJavaElement();
	change = new CompilationUnitChange(OVERRIDE_COPYRIGHT, unit);
	rewriter = ASTRewrite.create(compilationUnit.getAST());
	final List<Comment> comments = getCommentList(compilationUnit);
	Comment copyrightComment = null;
	if (!comments.isEmpty()) {
		copyrightComment = comments.get(0);
	}
	rewriteCompilationUnit(unit, getNewUnitSource(unit, copyrightComment));
	return change;
}
 
开发者ID:SAP,项目名称:hybris-commerce-eclipse-plugin,代码行数:20,代码来源:CopyrightManager.java

示例8: hasCopyrightsComment

import org.eclipse.jdt.core.dom.Comment; //导入依赖的package包/类
/**
 * Checks whether {@link CompilationUnit} has copyright header
 *
 * @param compilationUnit
 *            checked compilation unit
 * @return true if {@link CompilationUnit} has copyright header
 */
public boolean hasCopyrightsComment(final CompilationUnit compilationUnit) {
	final List<Comment> comments = getCommentList(compilationUnit);
	boolean hasCopyrights = false;
	if (!comments.isEmpty()) {
		final PackageDeclaration packageNode = compilationUnit.getPackage();
		final boolean commentBeforePackage = comments.get(0).getStartPosition() <= packageNode.getStartPosition();
		final boolean hasJavaDoc = packageNode.getJavadoc() != null;
		hasCopyrights = commentBeforePackage || hasJavaDoc;
	}
	return hasCopyrights;
}
 
开发者ID:SAP,项目名称:hybris-commerce-eclipse-plugin,代码行数:19,代码来源:CopyrightManager.java

示例9: getNewUnitSource

import org.eclipse.jdt.core.dom.Comment; //导入依赖的package包/类
/**
 * Gets compilation unit's source
 *
 * @param unit
 *            affected compilation unit
 * @param comment
 *            comment to be replaced; set null if comment is not present
 * @return new compilation unit's source
 */
private String getNewUnitSource(final ICompilationUnit unit, final Comment comment) {
	String source = null;
	try {
		source = unit.getSource();
		if (comment != null) {
			final int endOfComment = comment.getLength() + comment.getStartPosition();
			source = source.replace(source.substring(0, endOfComment), getCopyrightText());
		}
	} catch (final JavaModelException e) {
		ConsoleUtils.printError(e.getMessage());
	}
	return source;
}
 
开发者ID:SAP,项目名称:hybris-commerce-eclipse-plugin,代码行数:23,代码来源:CopyrightManager.java

示例10: extractCommentItem

import org.eclipse.jdt.core.dom.Comment; //导入依赖的package包/类
private final CommentItem extractCommentItem(final int index) {
    if (commentsVisited[index]) {
        return null;
    } else {
        final Comment comment = (Comment) comments.get(index);
        if (comment.isDocComment()) {
            /* Interpret DocComment as Line or Block */
            comment.delete();
        }
        final int start = comment.getStartPosition();
        final int end = start + comment.getLength();
        final String value = this.src.substring(start, end);
        return new CommentItem(comment, value);
    }
}
 
开发者ID:boalang,项目名称:compiler,代码行数:16,代码来源:UglyMathCommentsExtractor.java

示例11: getNodeFirstLeadingCommentIndex

import org.eclipse.jdt.core.dom.Comment; //导入依赖的package包/类
private final int getNodeFirstLeadingCommentIndex(final ASTNode node) {
    if (node instanceof PackageDeclaration) {
        if (commentsVisited.length > 0) {
            final Comment comment = (Comment) comments.get(0);
            if (comment.getStartPosition() + comment.getLength() <= ((PackageDeclaration) node).getName()
                    .getStartPosition()) {
                return 0;
            }
        }
        return -1;
    } else {
        return cu.firstLeadingCommentIndex(node);
    }
}
 
开发者ID:boalang,项目名称:compiler,代码行数:15,代码来源:UglyMathCommentsExtractor.java

示例12: getCommentContent

import org.eclipse.jdt.core.dom.Comment; //导入依赖的package包/类
/** Extract comment content from source. */
private String getCommentContent(Comment comment) {
   int start = comment.getStartPosition();
   int end = start + comment.getLength();
   String content = routeSource.substring(start, end);
   if (content.startsWith("//")) {
      content = content.substring(2).trim();
   }
   return content;
}
 
开发者ID:lbroudoux,项目名称:eip-designer,代码行数:11,代码来源:CamelJavaFileParser.java

示例13: postVisit

import org.eclipse.jdt.core.dom.Comment; //导入依赖的package包/类
@Override
public void postVisit(ASTNode node) {
	//super.postVisit(node);
	// Skip CU
	if (node instanceof CompilationUnit || node instanceof Comment) {
		return;
	}
	doComments(node, true);
}
 
开发者ID:mrmonday,项目名称:j2d,代码行数:10,代码来源:J2dVisitor.java

示例14: serializeAll

import org.eclipse.jdt.core.dom.Comment; //导入依赖的package包/类
private void serializeAll(CompilationUnit cu, ASTNode node, JsonGenerator jG, SerializerProvider provider) throws IOException {
    List<StructuralPropertyDescriptor> descriptorList = node.structuralPropertiesForType();
    jG.writeStartObject();

    final int Ntype = node.getNodeType();
    String ClassName = node.nodeClassForType(Ntype).getName().substring(25);
    jG.writeFieldName("internalClass");
    jG.writeString(ClassName);

    for (StructuralPropertyDescriptor descriptor : descriptorList) {
        Object child = node.getStructuralProperty(descriptor);
        if (child instanceof List) {
            serializeChildList(cu, (List<ASTNode>) child, jG, descriptor, provider);
        } else if (child instanceof ASTNode) {
            serializeChild(cu, (ASTNode) child, jG, descriptor, provider);
        } else if (child != null) {
            jG.writeFieldName(descriptor.getId());
            jG.writeString(child.toString());
            serializePosition(cu, node, jG);
        }
    }

    if (node == cu) {
        List<Comment> cl = cu.getCommentList();
        if (!cl.isEmpty()) {
            jG.writeFieldName("comments");
            jG.writeStartArray();
            for (Comment c: (List<Comment>) cu.getCommentList()) {
                if (c.getParent() != null) continue;
                jG.writeStartObject();
                final int type = c.getNodeType();
                String name = c.nodeClassForType(type).getName().substring(25);
                jG.writeFieldName("internalClass");
                jG.writeString(name);
                serializePosition(cu, (ASTNode)c, jG);
                jG.writeEndObject();
            }
            jG.writeEndArray();
        }
    }

    jG.writeEndObject();
}
 
开发者ID:bblfsh,项目名称:java-driver,代码行数:44,代码来源:CompilationUnitSerializer.java

示例15: CommentItem

import org.eclipse.jdt.core.dom.Comment; //导入依赖的package包/类
protected CommentItem(final Comment node, final String value) {
    this.node = node;
    this.value = value;
}
 
开发者ID:boalang,项目名称:compiler,代码行数:5,代码来源:ICommentsExtractor.java


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