// Transmogrify License
//
// Copyright (c) 2001, ThoughtWorks, Inc.
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// - Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// - Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// Neither the name of the ThoughtWorks, Inc. nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
import java.util.Vector;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogConfigurationException;
import org.apache.commons.logging.LogFactory;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
/**
* The resolver is responsible for traversing all the various
* definitions in a symbol table and resolving references in them.
*
* @see SymbolTable
*/
public class Resolver extends DefinitionTraverser {
/** true if the log factory has been initialized */
private boolean mInitialized = false;
/** Factory for creating org.apache.commons.logging.Log instances */
private LogFactory mLogFactory;
/**
* constructor with <code>SymbolTable</code> to be resolved
*/
public Resolver(SymbolTable symbolTable) {
super(symbolTable);
try {
mLogFactory = LogFactory.getFactory();
}
catch (LogConfigurationException e) {
System.out.println("log configuration exception" + e);
}
mInitialized = true;
}
/**
* resolves the symbol table
* @return <code>void</code>
* @see #traverse()
*/
public void resolve() {
traverse();
}
protected void handleSList(SymTabAST node, Scope scope) {
SymTabASTIterator iterator = node.getChildren();
while (iterator.hasNext()) {
SymTabAST current = iterator.nextChild();
resolveExpression(current, scope, null, true);
}
}
protected void handleAnonymousInnerClass(AnonymousInnerClass innerClass) {
SymTabAST objblock = innerClass.getTreeNode();
SymTabAST expression = (SymTabAST) objblock.getFirstChild();
while (expression != null) {
resolveExpression(expression, innerClass, null, true);
expression = (SymTabAST) expression.getNextSibling();
}
}
/**
* processes a <code>ClassDef</code> and resolves references in it
*
* @param classDef the <code>ClassDef</code> to process
*/
protected void handleClass(ClassDef classDef) {
SymTabAST node = classDef.getTreeNode();
if (node != null) {
SymTabAST nameNode = node.findFirstToken(TokenTypes.IDENT);
nameNode.setDefinition(classDef, classDef, true);
SymTabAST extendsClause =
node.findFirstToken(TokenTypes.EXTENDS_CLAUSE);
if(extendsClause != null) {
SymTabAST extendedClassNode =
(SymTabAST) extendsClause.getFirstChild();
while (extendedClassNode != null) {
IClass superClass =
resolveClass(extendedClassNode, classDef, null, true);
extendedClassNode.setDefinition(superClass, classDef, true);
extendedClassNode =
(SymTabAST) extendedClassNode.getNextSibling();
}
}
SymTabAST implementsNode =
node.findFirstToken(TokenTypes.IMPLEMENTS_CLAUSE);
if (implementsNode != null) {
SymTabAST interfaceNode =
(SymTabAST) (implementsNode.getFirstChild());
while (interfaceNode != null) {
resolveClass(interfaceNode, classDef, null, true);
interfaceNode =
(SymTabAST) (interfaceNode.getNextSibling());
}
}
}
}
/**
* processes a <code>MethodDef</code> and resolves references in it
*
* @param method the <code>MethodDef</code> to process
*/
protected void handleMethod(MethodDef method) {
SymTabAST node = method.getTreeNode();
SymTabAST nameNode = node.findFirstToken(TokenTypes.IDENT);
nameNode.setDefinition(method, method, true);
// references to classes in return type
SymTabAST returnTypeNode = node.findFirstToken(TokenTypes.TYPE);
if (returnTypeNode != null) {
// this is not a constructor
resolveExpression(returnTypeNode, method, null, true);
}
SymTabAST throwsNode =
node.findFirstToken(TokenTypes.LITERAL_THROWS);
if (throwsNode != null) {
SymTabAST exception = (SymTabAST) throwsNode.getFirstChild();
while (exception != null) {
// handle Checkstyle grammar
if (exception.getType() != TokenTypes.COMMA) {
resolveClass(exception, method, null, true);
}
exception = (SymTabAST) exception.getNextSibling();
}
}
// references to classes in parameters
// the body -- this would be better its own function
SymTabAST slist = node.findFirstToken(TokenTypes.SLIST);
if (slist != null) {
handleSList(slist, method);
}
}
/**
* processes a <code>BlockDef</code> and resolves references in it
*
* @param block the <code>BlockDef</code> to process
*/
protected void handleBlock(BlockDef block) {
SymTabAST node = block.getTreeNode();
switch (node.getType()) {
case TokenTypes.LITERAL_FOR :
handleFor(block);
break;
case TokenTypes.LITERAL_IF :
handleIf(block);
break;
case TokenTypes.LITERAL_WHILE :
handleWhileAndSynchronized(block);
break;
case TokenTypes.LITERAL_DO :
handleDoWhile(block);
break;
case TokenTypes.LITERAL_TRY :
case TokenTypes.LITERAL_FINALLY :
SymTabAST slist = node.findFirstToken(TokenTypes.SLIST);
handleSList(slist, block);
break;
case TokenTypes.LITERAL_CATCH :
handleCatch(block);
break;
case TokenTypes.LITERAL_SWITCH :
handleSwitch(block);
break;
case TokenTypes.SLIST :
handleSLis
没有合适的资源?快使用搜索试试~ 我知道了~
Checkstyle
共359个文件
html:175个
java:124个
xml:18个
3星 · 超过75%的资源 需积分: 14 120 下载量 54 浏览量
2007-10-14
11:06:00
上传
评论 1
收藏 3.2MB ZIP 举报
温馨提示
介绍 Checkstyle是一个开发工具,可以帮助编程人员编写符合编码规范的java 代码 。程序员都非常讨厌程序的check工作,checkstyle能够自动地完成这项烦琐但又非常重要的工作 ,从而节省了的程序员的时间,也提高了检查的质量。Checkstyle已经成了加强编码规范的首选工具。 NtCheckstyle 是一个可安装的模块,它自动完成Checkstyle和Netbeans 环境的集成。集成后checkstyle的使用非常的方便。 安装 你可以在Netbeans中直接安装NbCheckstyle。<br>
资源推荐
资源详情
资源评论
收起资源包目录
Checkstyle (359个子文件)
RIGHTS.antlr 1KB
LICENSE.apache 3KB
LICENSE.apache20 11KB
cs-style.css 5KB
site.css 2KB
stylesheet.css 1KB
cs-layout.css 548B
AuditListener.gif 6KB
Filter.gif 3KB
inherit.gif 57B
java.header 1KB
TokenTypes.html 224KB
index-all.html 222KB
config_coding.html 189KB
config_misc.html 135KB
config.html 101KB
config_whitespace.html 88KB
config_javadoc.html 72KB
releasenotes.html 70KB
constant-values.html 68KB
configuration.html 59KB
availablechecks.html 55KB
config_j2ee.html 44KB
config_blocks.html 43KB
config_sizes.html 43KB
config_metrics.html 42KB
config_header.html 42KB
writingchecks.html 41KB
AbstractViolationReporter.html 40KB
Checker.html 40KB
config_design.html 39KB
Check.html 38KB
AbstractFileSetCheck.html 36KB
DetailAST.html 36KB
anttask.html 35KB
LocalizedMessage.html 34KB
CheckStyleTask.html 34KB
config_imports.html 34KB
TreeWalker.html 33KB
AbstractLoader.html 32KB
writinglisteners.html 31KB
AuditEvent.html 30KB
Utils.html 30KB
FileContents.html 28KB
DefaultLogger.html 27KB
SuppressionCommentFilter.html 26KB
XMLLogger.html 26KB
CheckstyleException.html 26KB
PackageNamesLoader.html 25KB
DetailAST.html 25KB
AuditEvent.html 25KB
config_naming.html 24KB
overview-tree.html 24KB
package-use.html 24KB
SeverityLevelCounter.html 23KB
cmdline.html 23KB
AutomaticBean.html 23KB
SuppressElement.html 22KB
DefaultConfiguration.html 22KB
property_types.html 22KB
Scope.html 22KB
SuppressionsLoader.html 22KB
ScopeUtils.html 22KB
SeverityLevel.html 22KB
SuppressionCommentFilter.Tag.html 21KB
Configuration.html 21KB
FilterSet.html 20KB
SuppressionFilter.html 20KB
index.html 19KB
ConfigurationLoader.html 18KB
config_duplicates.html 18KB
package-tree.html 18KB
SeverityMatchFilter.html 17KB
SeverityLevel.html 17KB
config_modifier.html 17KB
FullIdent.html 17KB
CheckstyleException.html 17KB
Contextualizable.html 16KB
Configurable.html 16KB
DefaultContext.html 16KB
CheckStyleTask.Formatter.html 16KB
CheckStyleTask.Property.html 16KB
serialized-form.html 16KB
AuditListener.html 16KB
Filter.html 16KB
package-summary.html 16KB
writingfilters.html 16KB
TokenTypesDoclet.html 15KB
CheckDocsDoclet.html 15KB
AutomaticBean.html 15KB
LocalizedMessages.html 15KB
PropertiesExpander.html 15KB
FileContents.html 14KB
Scope.html 14KB
LocalizedMessage.html 14KB
CheckStyleTask.FormatterType.html 14KB
AuditListener.html 14KB
FileSetCheck.html 14KB
CheckStyleTask.Listener.html 14KB
package-tree.html 13KB
共 359 条
- 1
- 2
- 3
- 4
资源评论
- vipcowrie2013-09-12好工具,感谢分享。
- lhzhentaoyana2012-05-25下载几种静态分析工具做比较,这个是比较典型的一个
- 努力新人2018-03-15谢谢,群主的共享,非常感谢.
Zero-point
- 粉丝: 2
- 资源: 35
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功