本文整理汇总了Java中net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit类的典型用法代码示例。如果您正苦于以下问题:Java ASTCompilationUnit类的具体用法?Java ASTCompilationUnit怎么用?Java ASTCompilationUnit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ASTCompilationUnit类属于net.sourceforge.pmd.lang.java.ast包,在下文中一共展示了ASTCompilationUnit类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: test
import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit; //导入依赖的package包/类
@Test
public void test() throws Exception {
FullyQualifiedName fqn = new FullyQualifiedName("foo.bar", "Baz");
FullyQualifiedName abstractFQN = new FullyQualifiedName("foo.bar", "AbstractBaz");
String nullableDescription = null;
ModuleMXBeanEntry moduleMXBeanEntry = mockModuleMXBeanEntry(fqn, abstractFQN, nullableDescription);
Optional<String> copyright = Optional.absent();
Optional<String> header = Optional.absent();
GeneratedObject go = new ConcreteModuleGeneratedObjectFactory().toGeneratedObject(moduleMXBeanEntry, copyright, header);
Entry<FullyQualifiedName, File> entry = go.persist(generatorOutputPath).get();
File dstFile = entry.getValue();
Node c = parse(dstFile);
assertEquals(fqn.getPackageName(), ((ASTCompilationUnit) c).getPackageDeclaration().getPackageNameImage());
assertEquals(fqn.getTypeName(), c.getFirstDescendantOfType(ASTClassOrInterfaceDeclaration.class).getImage());
assertHasMethodNamed(c, "customValidation");
assertHasMethodNamed(c, "createInstance");
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:20,代码来源:ConcreteModuleGeneratedObjectFactoryTest.java
示例2: analyze
import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected void analyze(IJavaElement classElement, JavaClass clazz) {
int maxLength = 0;
ASTCompilationUnit ast;
try {
ast = JavaLibrary.getInstance().getAST(classElement);
} catch (ConQATException e) {
getLogger().error("Could not get AST for " + classElement.getId(),
e);
return;
}
for (ASTMethodDeclaration method : ast
.findChildrenOfType(ASTMethodDeclaration.class)) {
int length = method.getEndLine() - method.getBeginLine() + 1;
maxLength = Math.max(maxLength, length);
}
classElement.setValue(LONGEST_METHOD_KEY, maxLength);
}
开发者ID:vimaier,项目名称:conqat,代码行数:21,代码来源:LongestMethodLengthAnalyzer.java
示例3: initDFA
import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit; //导入依赖的package包/类
/** Initialized data flow analysis if needed. */
private void initDFA(ASTCompilationUnit unit) {
boolean needsDFA = ruleSet.usesDFA(Language.JAVA);
for (RuleSets rs : ruleSetsList) {
if (rs.usesDFA(Language.JAVA)) {
needsDFA = true;
}
}
if (needsDFA) {
DataFlowHandler dataFlowHandler = new JavaDataFlowHandler();
new DataFlowFacade().initializeWith(dataFlowHandler, unit);
}
}
开发者ID:vimaier,项目名称:conqat,代码行数:14,代码来源:PMDAnalyzerDelegate.java
示例4: getImports
import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit; //导入依赖的package包/类
protected static final List<ASTImportDeclaration> getImports(AbstractJavaNode node) {
ASTCompilationUnit cu = node.getFirstParentOfType(ASTCompilationUnit.class);
if (cu == null) {
return Collections.emptyList();
}
return cu.findChildrenOfType(ASTImportDeclaration.class);
}
开发者ID:AludraTest,项目名称:aludratest,代码行数:9,代码来源:AbstractAludraTestRule.java
示例5: getAST
import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit; //导入依赖的package包/类
/**
* Get AST for a class element.
*
* @return the AST
* @throws ConQATException
* if parsing fails
*/
public ASTCompilationUnit getAST(ITokenElement element)
throws ConQATException {
return astCache.obtain(new JavaASTCacheKey(element));
}
开发者ID:vimaier,项目名称:conqat,代码行数:12,代码来源:JavaLibrary.java
注:本文中的net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论