Showing preview only (1,196K chars total). Download the full file or copy to clipboard to get everything.
Repository: alibaba/p3c
Branch: master
Commit: 6c59c8c36ecd
Files: 329
Total size: 1.1 MB
Directory structure:
gitextract_c6djlc1m/
├── .github/
│ └── ISSUE_TEMPLATE/
│ ├── ------.md
│ ├── bug_report.md
│ ├── feature_request.md
│ └── rule-issue-template.md
├── .gitignore
├── README.md
├── eclipse-plugin/
│ ├── .gitignore
│ ├── README.md
│ ├── README_cn.md
│ ├── com.alibaba.smartfox.eclipse.feature/
│ │ ├── build.properties
│ │ ├── feature.properties
│ │ ├── feature.xml
│ │ └── pom.xml
│ ├── com.alibaba.smartfox.eclipse.plugin/
│ │ ├── META-INF/
│ │ │ └── MANIFEST.MF
│ │ ├── build.properties
│ │ ├── plugin.xml
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── kotlin/
│ │ │ └── com/
│ │ │ └── alibaba/
│ │ │ └── smartfox/
│ │ │ └── eclipse/
│ │ │ ├── QuickFix.kt
│ │ │ ├── SmartfoxActivator.kt
│ │ │ ├── handler/
│ │ │ │ ├── CodeAnalysisHandler.kt
│ │ │ │ └── SwitchLanguageHandler.kt
│ │ │ ├── job/
│ │ │ │ ├── CodeAnalysis.kt
│ │ │ │ └── P3cMutex.kt
│ │ │ ├── message/
│ │ │ │ └── P3cBundle.kt
│ │ │ ├── pmd/
│ │ │ │ ├── RulePriority.kt
│ │ │ │ └── rule/
│ │ │ │ ├── AbstractEclipseRule.kt
│ │ │ │ ├── AvoidAccessStaticViaInstanceRule.kt
│ │ │ │ ├── AvoidUseDeprecationRule.kt
│ │ │ │ ├── MapOrSetKeyShouldOverrideHashCodeEqualsRule.kt
│ │ │ │ └── MissingOverrideAnnotationRule.kt
│ │ │ ├── ui/
│ │ │ │ ├── AllRulesPreferencePage.kt
│ │ │ │ ├── AllRulesView.kt
│ │ │ │ ├── InspectionResultTreeContentProvider.kt
│ │ │ │ ├── InspectionResultTreeLabelProvider.kt
│ │ │ │ ├── InspectionResultView.kt
│ │ │ │ ├── InspectionResults.kt
│ │ │ │ ├── QuickFixAction.kt
│ │ │ │ ├── RuleDetailComposite.kt
│ │ │ │ ├── RuleDetailView.kt
│ │ │ │ ├── Violations.kt
│ │ │ │ └── pmd/
│ │ │ │ ├── BasicLineStyleListener.kt
│ │ │ │ ├── ContentBuilder.kt
│ │ │ │ ├── FontBuilder.kt
│ │ │ │ ├── StringArranger.kt
│ │ │ │ ├── StyleExtractor.kt
│ │ │ │ ├── SyntaxData.kt
│ │ │ │ └── SyntaxManager.kt
│ │ │ └── util/
│ │ │ ├── CleanUps.kt
│ │ │ └── MarkerUtil.kt
│ │ └── resources/
│ │ ├── messages/
│ │ │ ├── P3cBundle.xml
│ │ │ └── P3cBundle_en.xml
│ │ ├── rulesets/
│ │ │ └── java/
│ │ │ ├── ali-pmd.xml
│ │ │ └── ali-ruleOnEclipse.xml
│ │ └── syntax/
│ │ └── java.properties
│ ├── com.alibaba.smartfox.eclipse.updatesite/
│ │ ├── category.xml
│ │ └── pom.xml
│ └── pom.xml
├── idea-plugin/
│ ├── .gitignore
│ ├── README.md
│ ├── README_cn.md
│ ├── build.gradle
│ ├── gradle/
│ │ └── wrapper/
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
│ ├── gradle.properties
│ ├── gradlew
│ ├── gradlew.bat
│ ├── p3c-common/
│ │ ├── build.gradle
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── icons/
│ │ │ └── P3cIcons.java
│ │ ├── kotlin/
│ │ │ └── com/
│ │ │ └── alibaba/
│ │ │ ├── p3c/
│ │ │ │ └── idea/
│ │ │ │ ├── action/
│ │ │ │ │ ├── AliInspectionAction.kt
│ │ │ │ │ ├── PmdGlobalInspectionContextImpl.kt
│ │ │ │ │ ├── SwitchLanguageAction.kt
│ │ │ │ │ └── ToggleProjectInspectionAction.kt
│ │ │ │ ├── compatible/
│ │ │ │ │ └── inspection/
│ │ │ │ │ ├── InspectionProfileService.kt
│ │ │ │ │ └── Inspections.kt
│ │ │ │ ├── component/
│ │ │ │ │ ├── AliProjectComponent.kt
│ │ │ │ │ └── CommonSettingsApplicationComponent.kt
│ │ │ │ ├── config/
│ │ │ │ │ ├── P3cConfig.kt
│ │ │ │ │ └── SmartFoxProjectConfig.kt
│ │ │ │ ├── ep/
│ │ │ │ │ ├── InspectionActionExtensionPoint.kt
│ │ │ │ │ └── package-info.java
│ │ │ │ ├── i18n/
│ │ │ │ │ └── P3cBundle.kt
│ │ │ │ ├── inspection/
│ │ │ │ │ ├── AliAccessToNonThreadSafeStaticFieldFromInstanceInspection.kt
│ │ │ │ │ ├── AliArrayNamingShouldHaveBracketInspection.kt
│ │ │ │ │ ├── AliBaseInspection.kt
│ │ │ │ │ ├── AliControlFlowStatementWithoutBracesInspection.kt
│ │ │ │ │ ├── AliEqualsAvoidNullInspection.kt
│ │ │ │ │ ├── AliLocalInspectionToolProvider.kt
│ │ │ │ │ ├── AliLongLiteralsEndingWithLowercaseLInspection.kt
│ │ │ │ │ ├── AliPmdInspection.kt
│ │ │ │ │ ├── AliPmdInspectionInvoker.kt
│ │ │ │ │ ├── AliWrapperTypeEqualityInspection.kt
│ │ │ │ │ ├── DelegateLocalInspectionTool.kt
│ │ │ │ │ ├── DelegatePmdInspection.kt
│ │ │ │ │ ├── PmdRuleInspectionIdentify.kt
│ │ │ │ │ ├── RuleInspectionUtils.kt
│ │ │ │ │ └── standalone/
│ │ │ │ │ ├── AliAccessStaticViaInstanceInspection.kt
│ │ │ │ │ ├── AliDeprecationInspection.kt
│ │ │ │ │ ├── AliMissingOverrideAnnotationInspection.kt
│ │ │ │ │ └── MapOrSetKeyShouldOverrideHashCodeEqualsInspection.kt
│ │ │ │ ├── pmd/
│ │ │ │ │ ├── AliPmdProcessor.kt
│ │ │ │ │ ├── SourceCodeProcessor.kt
│ │ │ │ │ └── index/
│ │ │ │ │ ├── InspectionDataSource.kt
│ │ │ │ │ └── InspectionRenderer.kt
│ │ │ │ ├── quickfix/
│ │ │ │ │ ├── AliQuickFix.kt
│ │ │ │ │ ├── AvoidStartWithDollarAndUnderLineNamingQuickFix.kt
│ │ │ │ │ ├── ClassMustHaveAuthorQuickFix.kt
│ │ │ │ │ ├── ConstantFieldShouldBeUpperCaseQuickFix.kt
│ │ │ │ │ ├── DecorateInspectionFix.kt
│ │ │ │ │ ├── LowerCamelCaseVariableNamingQuickFix.kt
│ │ │ │ │ └── VmQuietReferenceQuickFix.kt
│ │ │ │ ├── util/
│ │ │ │ │ ├── DocumentUtils.kt
│ │ │ │ │ ├── HighlightDisplayLevels.kt
│ │ │ │ │ ├── HighlightInfoTypes.kt
│ │ │ │ │ ├── HighlightSeverities.kt
│ │ │ │ │ ├── NumberConstants.kt
│ │ │ │ │ ├── ObjectConstants.kt
│ │ │ │ │ ├── ProblemsUtils.kt
│ │ │ │ │ ├── QuickFixes.kt
│ │ │ │ │ └── withLockNotInline.kt
│ │ │ │ └── vcs/
│ │ │ │ ├── AliCodeAnalysisCheckinHandler.kt
│ │ │ │ └── AliCodeAnalysisCheckinHandlerFactory.kt
│ │ │ └── smartfox/
│ │ │ └── idea/
│ │ │ └── common/
│ │ │ ├── component/
│ │ │ │ ├── AliBaseApplicationComponent.kt
│ │ │ │ └── AliBaseProjectComponent.kt
│ │ │ └── util/
│ │ │ ├── BalloonNotifications.kt
│ │ │ ├── CommonExtensions.kt
│ │ │ └── PluginVersions.kt
│ │ └── resources/
│ │ ├── messages/
│ │ │ ├── P3cBundle.xml
│ │ │ └── P3cBundle_en.xml
│ │ ├── rulesets/
│ │ │ └── java/
│ │ │ └── ali-pmd.xml
│ │ └── tpl/
│ │ └── StaticDescriptionTemplate.ftl
│ ├── p3c-idea/
│ │ ├── build.gradle
│ │ └── src/
│ │ └── main/
│ │ └── resources/
│ │ └── META-INF/
│ │ ├── p3c.xml
│ │ └── plugin.xml
│ └── settings.gradle
├── license.txt
├── p3c-formatter/
│ ├── eclipse-codestyle.xml
│ └── eclipse-codetemplate.xml
├── p3c-gitbook/
│ ├── .gitignore
│ ├── MySQL数据库/
│ │ ├── ORM映射.md
│ │ ├── SQL语句.md
│ │ ├── 建表规约.md
│ │ └── 索引规约.md
│ ├── README.md
│ ├── SUMMARY.md
│ ├── book.json
│ ├── styles/
│ │ └── website.css
│ ├── 单元测试.md
│ ├── 安全规约.md
│ ├── 工程结构/
│ │ ├── 二方库依赖.md
│ │ ├── 应用分层.md
│ │ └── 服务器.md
│ ├── 异常日志/
│ │ ├── 其他.md
│ │ ├── 异常处理.md
│ │ └── 日志规约.md
│ ├── 本手册专有名词.md
│ ├── 版本历史.md
│ └── 编程规约/
│ ├── OOP规范.md
│ ├── 代码格式.md
│ ├── 命名风格.md
│ ├── 常量定义.md
│ ├── 并发处理.md
│ ├── 控制语句.md
│ ├── 注释规约.md
│ └── 集合处理.md
└── p3c-pmd/
├── .gitignore
├── README.md
├── pom.xml
└── src/
├── main/
│ ├── java/
│ │ └── com/
│ │ └── alibaba/
│ │ └── p3c/
│ │ └── pmd/
│ │ ├── I18nResources.java
│ │ ├── fix/
│ │ │ └── FixClassTypeResolver.java
│ │ └── lang/
│ │ ├── AbstractXpathRule.java
│ │ ├── java/
│ │ │ ├── rule/
│ │ │ │ ├── AbstractAliRule.java
│ │ │ │ ├── AbstractPojoRule.java
│ │ │ │ ├── comment/
│ │ │ │ │ ├── AbstractAliCommentRule.java
│ │ │ │ │ ├── AbstractMethodOrInterfaceMethodMustUseJavadocRule.java
│ │ │ │ │ ├── AvoidCommentBehindStatementRule.java
│ │ │ │ │ ├── ClassMustHaveAuthorRule.java
│ │ │ │ │ ├── CommentsMustBeJavadocFormatRule.java
│ │ │ │ │ ├── EnumConstantsMustHaveCommentRule.java
│ │ │ │ │ └── RemoveCommentedCodeRule.java
│ │ │ │ ├── concurrent/
│ │ │ │ │ ├── AvoidCallStaticSimpleDateFormatRule.java
│ │ │ │ │ ├── AvoidConcurrentCompetitionRandomRule.java
│ │ │ │ │ ├── AvoidManuallyCreateThreadRule.java
│ │ │ │ │ ├── AvoidUseTimerRule.java
│ │ │ │ │ ├── CountDownShouldInFinallyRule.java
│ │ │ │ │ ├── ThreadLocalShouldRemoveRule.java
│ │ │ │ │ ├── ThreadPoolCreationRule.java
│ │ │ │ │ └── ThreadShouldSetNameRule.java
│ │ │ │ ├── constant/
│ │ │ │ │ ├── UndefineMagicConstantRule.java
│ │ │ │ │ └── UpperEllRule.java
│ │ │ │ ├── exception/
│ │ │ │ │ ├── AvoidReturnInFinallyRule.java
│ │ │ │ │ ├── MethodReturnWrapperTypeRule.java
│ │ │ │ │ └── TransactionMustHaveRollbackRule.java
│ │ │ │ ├── flowcontrol/
│ │ │ │ │ ├── AvoidComplexConditionRule.java
│ │ │ │ │ ├── AvoidNegationOperatorRule.java
│ │ │ │ │ ├── NeedBraceRule.java
│ │ │ │ │ └── SwitchStatementRule.java
│ │ │ │ ├── naming/
│ │ │ │ │ ├── AbstractClassShouldStartWithAbstractNamingRule.java
│ │ │ │ │ ├── ArrayNamingShouldHaveBracketRule.java
│ │ │ │ │ ├── AvoidStartWithDollarAndUnderLineNamingRule.java
│ │ │ │ │ ├── BooleanPropertyShouldNotStartWithIsRule.java
│ │ │ │ │ ├── ClassNamingShouldBeCamelRule.java
│ │ │ │ │ ├── ConstantFieldShouldBeUpperCaseRule.java
│ │ │ │ │ ├── ExceptionClassShouldEndWithExceptionRule.java
│ │ │ │ │ ├── LowerCamelCaseVariableNamingRule.java
│ │ │ │ │ ├── PackageNamingRule.java
│ │ │ │ │ ├── ServiceOrDaoClassShouldEndWithImplRule.java
│ │ │ │ │ └── TestClassShouldEndWithTestNamingRule.java
│ │ │ │ ├── oop/
│ │ │ │ │ ├── BigDecimalAvoidDoubleConstructorRule.java
│ │ │ │ │ ├── EqualsAvoidNullRule.java
│ │ │ │ │ ├── PojoMustOverrideToStringRule.java
│ │ │ │ │ ├── PojoMustUsePrimitiveFieldRule.java
│ │ │ │ │ ├── PojoNoDefaultValueRule.java
│ │ │ │ │ ├── StringConcatRule.java
│ │ │ │ │ └── WrapperTypeEqualityRule.java
│ │ │ │ ├── orm/
│ │ │ │ │ └── IbatisMethodQueryForListRule.java
│ │ │ │ ├── other/
│ │ │ │ │ ├── AvoidApacheBeanUtilsCopyRule.java
│ │ │ │ │ ├── AvoidDoubleOrFloatEqualCompareRule.java
│ │ │ │ │ ├── AvoidMissUseOfMathRandomRule.java
│ │ │ │ │ ├── AvoidNewDateGetTimeRule.java
│ │ │ │ │ ├── AvoidPatternCompileInMethodRule.java
│ │ │ │ │ ├── MethodTooLongRule.java
│ │ │ │ │ └── UseRightCaseForDateFormatRule.java
│ │ │ │ ├── set/
│ │ │ │ │ ├── ClassCastExceptionWithSubListToArrayListRule.java
│ │ │ │ │ ├── ClassCastExceptionWithToArrayRule.java
│ │ │ │ │ ├── CollectionInitShouldAssignCapacityRule.java
│ │ │ │ │ ├── ConcurrentExceptionWithModifyOriginSubListRule.java
│ │ │ │ │ ├── DontModifyInForeachCircleRule.java
│ │ │ │ │ └── UnsupportedExceptionWithModifyAsListRule.java
│ │ │ │ └── util/
│ │ │ │ ├── NodeSortUtils.java
│ │ │ │ └── NodeUtils.java
│ │ │ └── util/
│ │ │ ├── GeneratedCodeUtils.java
│ │ │ ├── NumberConstants.java
│ │ │ ├── PojoUtils.java
│ │ │ ├── SpiLoader.java
│ │ │ ├── StringAndCharConstants.java
│ │ │ ├── VariableUtils.java
│ │ │ ├── ViolationUtils.java
│ │ │ └── namelist/
│ │ │ ├── NameListConfig.java
│ │ │ ├── NameListService.java
│ │ │ └── NameListServiceImpl.java
│ │ └── vm/
│ │ └── rule/
│ │ └── other/
│ │ └── UseQuietReferenceNotationRule.java
│ ├── kotlin/
│ │ └── com/
│ │ └── alibaba/
│ │ └── p3c/
│ │ └── pmd/
│ │ └── lang/
│ │ └── java/
│ │ └── rule/
│ │ └── concurrent/
│ │ └── LockShouldWithTryFinallyRule.kt
│ └── resources/
│ ├── META-INF/
│ │ └── services/
│ │ └── com.alibaba.p3c.pmd.lang.java.util.namelist.NameListService
│ ├── messages.xml
│ ├── messages_en.xml
│ ├── namelist.properties
│ └── rulesets/
│ ├── java/
│ │ ├── ali-comment.xml
│ │ ├── ali-concurrent.xml
│ │ ├── ali-constant.xml
│ │ ├── ali-exception.xml
│ │ ├── ali-flowcontrol.xml
│ │ ├── ali-naming.xml
│ │ ├── ali-oop.xml
│ │ ├── ali-orm.xml
│ │ ├── ali-other.xml
│ │ └── ali-set.xml
│ └── vm/
│ └── ali-other.xml
└── test/
├── java/
│ └── com/
│ └── alibaba/
│ └── p3c/
│ └── pmd/
│ ├── lang/
│ │ ├── java/
│ │ │ └── rule/
│ │ │ ├── comment/
│ │ │ │ └── CommentRulesTest.java
│ │ │ ├── concurrent/
│ │ │ │ └── ConcurrentRuleTest.java
│ │ │ ├── constant/
│ │ │ │ └── ConstantRulesTest.java
│ │ │ ├── exception/
│ │ │ │ └── ExceptionRulesTest.java
│ │ │ ├── flowcontrol/
│ │ │ │ └── FlowControlRuleTest.java
│ │ │ ├── naming/
│ │ │ │ └── NamingRulesTest.java
│ │ │ ├── oop/
│ │ │ │ └── OopRuleTest.java
│ │ │ ├── orm/
│ │ │ │ └── OrmRulesTest.java
│ │ │ ├── other/
│ │ │ │ ├── OtherRulesTest.java
│ │ │ │ └── UseRightCaseForDateFormatRuleTest.java
│ │ │ └── set/
│ │ │ └── SetRulesTest.java
│ │ └── vm/
│ │ └── rule/
│ │ └── other/
│ │ └── OtherRulesTest.java
│ └── testframework/
│ ├── ExtendRuleTst.java
│ └── ExtendSimpleAggregatorTst.java
└── resources/
└── com/
└── alibaba/
└── p3c/
└── pmd/
└── lang/
├── java/
│ └── rule/
│ ├── comment/
│ │ └── xml/
│ │ ├── AbstractMethodOrInterfaceMethodMustUseJavadocRule.xml
│ │ ├── AvoidCommentBehindStatementRule.xml
│ │ ├── ClassMustHaveAuthorRule.xml
│ │ ├── CommentsMustBeJavadocFormatRule.xml
│ │ ├── EnumConstantsMustHaveCommentRule.xml
│ │ └── RemoveCommentedCodeRule.xml
│ ├── concurrent/
│ │ └── xml/
│ │ ├── AvoidCallStaticSimpleDateFormatRule.xml
│ │ ├── AvoidConcurrentCompetitionRandomRule.xml
│ │ ├── AvoidManuallyCreateThreadRule.xml
│ │ ├── AvoidUseTimerRule.xml
│ │ ├── CountDownShouldInFinallyRule.xml
│ │ ├── LockShouldWithTryFinallyRule.xml
│ │ ├── ThreadLocalShouldRemoveRule.xml
│ │ ├── ThreadPoolCreationRule.xml
│ │ └── ThreadShouldSetNameRule.xml
│ ├── constant/
│ │ └── xml/
│ │ ├── UndefineMagicConstantRule.xml
│ │ └── UpperEllRule.xml
│ ├── exception/
│ │ └── xml/
│ │ ├── AvoidReturnInFinallyRule.xml
│ │ ├── MethodReturnWrapperTypeRule.xml
│ │ └── TransactionMustHaveRollbackRule.xml
│ ├── flowcontrol/
│ │ └── xml/
│ │ ├── AvoidComplexConditionRule.xml
│ │ ├── AvoidNegationOperatorRule.xml
│ │ ├── NeedBraceRule.xml
│ │ └── SwitchStatementRule.xml
│ ├── naming/
│ │ └── xml/
│ │ ├── AbstractClassShouldStartWithAbstractNamingRule.xml
│ │ ├── ArrayNamingShouldHaveBracketRule.xml
│ │ ├── AvoidStartWithDollarAndUnderLineNamingRule.xml
│ │ ├── BooleanPropertyShouldNotStartWithIsRule.xml
│ │ ├── ClassNamingShouldBeCamelRule.xml
│ │ ├── ConstantFieldShouldBeUpperCaseRule.xml
│ │ ├── ExceptionClassShouldEndWithExceptionRule.xml
│ │ ├── LowerCamelCaseVariableNamingRule.xml
│ │ ├── PackageNamingRule.xml
│ │ ├── ServiceOrDaoClassShouldEndWithImplRule.xml
│ │ └── TestClassShouldEndWithTestNamingRule.xml
│ ├── oop/
│ │ └── xml/
│ │ ├── BigDecimalAvoidDoubleConstructorRule.xml
│ │ ├── EqualsAvoidNullRule.xml
│ │ ├── PojoMustOverrideToStringRule.xml
│ │ ├── PojoMustUsePrimitiveFieldRule.xml
│ │ ├── PojoNoDefaultValueRule.xml
│ │ ├── StringConcatRule.xml
│ │ └── WrapperTypeEqualityRule.xml
│ ├── orm/
│ │ └── xml/
│ │ └── IbatisMethodQueryForListRule.xml
│ ├── other/
│ │ ├── java/
│ │ │ └── UseRightCaseForDateFormatRuleExam.java
│ │ └── xml/
│ │ ├── AvoidApacheBeanUtilsCopyRule.xml
│ │ ├── AvoidDoubleOrFloatEqualCompareRule.xml
│ │ ├── AvoidMissUseOfMathRandomRule.xml
│ │ ├── AvoidNewDateGetTimeRule.xml
│ │ ├── AvoidPatternCompileInMethodRule.xml
│ │ ├── MethodTooLongRule.xml
│ │ └── UseRightCaseForDateFormatRule.xml
│ └── set/
│ └── xml/
│ ├── ClassCastExceptionWithSubListToArrayListRule.xml
│ ├── ClassCastExceptionWithToArrayRule.xml
│ ├── CollectionInitShouldAssignCapacityRule.xml
│ ├── ConcurrentExceptionWithModifyOriginSubListRule.xml
│ ├── DontModifyInForeachCircleRule.xml
│ └── UnsupportedExceptionWithModifyAsListRule.xml
└── vm/
└── rule/
└── other/
└── xml/
└── UseQuietReferenceNotationRule.xml
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/ISSUE_TEMPLATE/------.md
================================================
---
name: 规约问题模板
about: 规约问题请使用该模板
title: ''
labels: ''
assignees: ''
---
## 规约原文
## 问题描述
## 修改建议
================================================
FILE: .github/ISSUE_TEMPLATE/bug_report.md
================================================
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.
================================================
FILE: .github/ISSUE_TEMPLATE/feature_request.md
================================================
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
================================================
FILE: .github/ISSUE_TEMPLATE/rule-issue-template.md
================================================
---
name: Rule issue template
about: Rule issue please use this template.
title: ''
labels: ''
assignees: ''
---
## Rule content
## Problem description
## Advice
================================================
FILE: .gitignore
================================================
# Gradle
build
.gradle
testdata/
# Java gitignore #
.class
.log
# Package Files #
*.war
*.ear
#hsf files
configuration
# maven gitignore#
target/**
.svn/
# intelliJ.gitignore #
.idea
*.iml
*.ipr
*.iws
# Eclipse git ignore#
*.pydevproject
.project
.metadata
bin/**
*/bin/**
tmp/**
tmp/**/*
configuration/**
*.tmp
*.bak
*.orig
*.swp
*~.nib
.classpath
.settings/
.loadpath
.fileTable*
.cache
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
#log
*.log
*.log.*
# Windows Thumbs.db
*.db
# OSX
.DS_Store
# sass gitignore#
.sass-cache
.idea
# tcc_coverage
coverage.ec
config.client.*
temp/
*.pid
*.orig
hsf.configuration/
# code coverage report
*.ec
#hsf test
*.instance
out
!/p3c-idea/src/main/kotlin/com/alibaba/smartfox/work/tools/aone/ui/AoneBranchView.kt
================================================
FILE: README.md
================================================
# P3C
最新版本:黄山版(2022.2.3发布)
[](https://www.apache.org/licenses/LICENSE-2.0.html)
## <font color="green">Preface</font>
> We are pleased to present Alibaba Java Coding Guidelines which consolidates the best programming practices over the years from Alibaba Group's technical teams. A vast number of Java programming teams impose demanding requirements on code quality across projects as we encourage reuse and better understanding of each other's programs. We have seen many programming problems in the past. For example, defective database table structures and index designs may cause software architecture flaws and performance risks. Another example is confusing code structures being difficult to maintain. Furthermore, vulnerable code without authentication is prone to hackers’ attacks. To address these kinds of problems, we developed this document for Java developers at Alibaba.
For more information please refer the *Alibaba Java Coding Guidelines*:
- 中文版: 直接下载上方的PDF文件(黄山版)
- English Version: *[Alibaba Java Coding Guidelines](https://alibaba.github.io/Alibaba-Java-Coding-Guidelines)*
## <font color="green">Introduction</font>
The project consists of 3 parts:
- [PMD implementations](p3c-pmd)
- [IntelliJ IDEA plugin](idea-plugin)
- [Eclipse plugin](eclipse-plugin)
## <font color="green">Rules</font>
<font color="blue">Forty-nine rules are realized based on PMD, please refer the P3C-PMD documentation for more detailed information. Four rules are implemented within IDE plugins (IDEA and Eclipse) as follows:</font>
- ``[Mandatory]`` Using a deprecated class or method is prohibited.
Note: For example, decode(String source, String encode) should be used instead of the deprecated method decode(String encodeStr). Once an interface has been deprecated, the interface provider has the obligation to provide a new one. At the same time, client programmers have the obligation to check out what its new implementation is.
- ``[Mandatory]`` An overridden method from an interface or abstract class must be marked with @Override annotation.
Counter example: For getObject() and get0bject(), the first one has a letter 'O', and the second one has a number '0'. To accurately determine whether the overriding is successful, an @Override annotation is necessary. Meanwhile, once the method signature in the abstract class is changed, the implementation class will report a compile-time error immediately.
- ``[Mandatory]`` A static field or method should be directly referred by its class name instead of its corresponding object name.
- ``[Mandatory]`` The usage of hashCode and equals should follow:
1. Override hashCode if equals is overridden.
2. These two methods must be overridden for Set since they are used to ensure that no duplicate object will be inserted in Set.
3. These two methods must be overridden if self-defined object is used as the key of Map.
Note: String can be used as the key of Map since these two methods have been rewritten.
================================================
FILE: eclipse-plugin/.gitignore
================================================
# Gradle
build
.gradle
testdata/
# Java gitignore #
.class
.log
# Package Files #
*.war
*.ear
*.gradle
#hsf files
configuration
# maven gitignore#
target/**
.svn/
# intelliJ.gitignore #
.idea
*.iml
*.ipr
*.iws
*.bat
# Eclipse git ignore#
*.pydevproject
.project
.metadata
bin/**
*/bin/**
tmp/**
tmp/**/*
configuration/**
*.tmp
*.bak
*.orig
*.swp
*~.nib
.classpath
.settings/
.loadpath
.fileTable*
.cache
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
#log
*.log
*.log.*
# Windows Thumbs.db
*.db
# OSX
.DS_Store
# sass gitignore#
.sass-cache
.idea
# tcc_coverage
coverage.ec
config.client.*
temp/
*.pid
*.orig
hsf.configuration/
# code coverage report
*.ec
#hsf test
*.instance
**/target
.pmd
**/.pmd
================================================
FILE: eclipse-plugin/README.md
================================================
# Eclipse Plugin
---
## <font color="green">Prepare</font>
- Eclipse Juno+
- maven3.+
- JDK 1.7+
## <font color="green">Build</font>
```
mvn -U clean install
```
## [中文使用手册](README_cn.md)
## <font color="green">Install</font>
1. <font color="blue">Help >> Install New Software
then enter this update site URL [https://p3c.alibaba.com/plugin/eclipse/update](https://p3c.alibaba.com/plugin/eclipse/update)</font>

2. <font color="blue">Follow the wizard, restart Eclipse to take effect after install success.</font>
## <font color="green">Use</font>
1. <font color="blue">Switch language</font>

2. <font color="blue">Code Analyze </font>


================================================
FILE: eclipse-plugin/README_cn.md
================================================
> 首先非常感谢大家对插件的支持与意见,Eclipse的功能相对来说比较简单,希望有更多的同学加入进来一起完善。
## 插件安装
环境:JDK1.8,Eclipse4+。有同学遇到过这样的情况,安装插件重启后,发现没有对应的菜单项,从日志上也看不到相关的异常信息,最后把JDK从1.6升级到1.8解决问题。
Help -> Install New Software...

输入Update Site地址:https://p3c.alibaba.com/plugin/eclipse/update 回车,然后勾选Ali-CodeAnalysis,再一直点Next Next...按提示走下去就好。 然后就是提示重启了,安装完毕。

注意:有同学反映插件扫描会触发很多 "JPA Java Change Event Handler (Waiting)" 的任务,这个是Eclipse的一个[bug](https://bugs.eclipse.org/bugs/show_bug.cgi?id=387455),因为插件在扫描的时候会对文件进行标记,所以触发了JPA的任务。卸载JPA插件,或者尝试升级到最新版的Eclipse。附:[JPA project Change Event Handler问题解决](https://my.oschina.net/cimu/blog/278724)
## 插件使用
目前插件实现了开发手册中的53条规则,大部分基于PMD实现,其中有4条规则基于Eclipse实现,支持4条规则的QuickFix功能。
* 所有的覆写方法,必须加@Override注解,
* if/for/while/switch/do等保留字与左右括号之间都必须加空格,
* long或者Long初始赋值时,必须使用大写的L,不能是小写的l)
* Object的equals方法容易抛空指针异常,应使用常量或确定有值的对象来调用equals。
目前不支持代码实时检测,需要手动触发,希望更多的人加入进来一起把咱们的插件做得越来越好,尽量提升研发的使用体验。
### 代码扫描
可以通过右键菜单、Toolbar按钮两种方式手动触发代码检测。同时结果面板中可以对部分实现了QuickFix功能的规则进行快速修复。
#### 触发扫描
在当前编辑的文件中点击右键,可以在弹出的菜单中触发对该文件的检测。

在左侧的Project目录树种点击右键,可以触发对整个工程或者选择的某个目录、文件进行检测。

也可以通过Toolbar中的按钮来触发检测,目前Toolbar的按钮触发的检测范围与您IDE当时的焦点有关,如当前编辑的文件或者是Project目录树选中的项,是不是感觉与右键菜单的检测范围类似呢。

#### 扫描结果
简洁的结果面板,按规则等级分类,等级->规则->文件->违规项。同时还提供一个查看规则详情的界面。
清除结果标记更方便,支持上面提到的4条规则QuickFix。

#### 查看所有规则


#### 国际化


================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.feature/build.properties
================================================
bin.includes = feature.xml,\
feature.properties,\
smartfox.png
src.includes = build.properties,\
feature.properties,\
feature.xml,\
smartfox.png
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.feature/feature.properties
================================================
feature.label = Ali-CodeAnalysis
feature.provider_name = Alibaba
feature.update_site_name = Alibaba IDE Portal
description.text = Alibaba Java Coding Guidelines
description.url = https://github.com/alibaba/p3c
copyright.text =\
Copyright 2017 Alibaba Java Coding Guidelines
license.url = https://github.com/alibaba/p3c
license.text =\
Copyright 1999-2017 Alibaba Group. \n\
\n\
Licensed under the Apache License, Version 2.0 (the "License"); \n\
you may not use this file except in compliance with the License. \n\
You may obtain a copy of the License at \n\
\n\
http://www.apache.org/licenses/LICENSE-2.0 \n\
\n\
Unless required by applicable law or agreed to in writing, software \n\
distributed under the License is distributed on an "AS IS" BASIS, \n\
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \n\
See the License for the specific language governing permissions and \n\
limitations under the License. \n\
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.feature/feature.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<feature
id="com.alibaba.smartfox.eclipse.feature"
label="%feature.label"
version="2.0.1.qualifier"
provider-name="%feature.provider_name"
plugin="com.alibaba.smartfox.eclipse.plugin"
image="smartfox.png">
<description url="%description.url">
Alibaba Java Coding Guidelines
</description>
<copyright>
%copyright.text
</copyright>
<license url="%license.url">
%license.text
</license>
<url>
<update label="%feature.update_site_name" url="https://p3c.alibaba.com/plugin/eclipse/update"/>
</url>
<requires>
<import plugin="org.eclipse.ui"/>
<import plugin="org.eclipse.core.runtime"/>
<import plugin="org.eclipse.jdt.core"/>
<import plugin="org.eclipse.ui.ide"/>
<import plugin="org.eclipse.ui.views"/>
<import plugin="org.eclipse.core.resources"/>
<import plugin="org.eclipse.jface.text"/>
<import plugin="org.eclipse.ui.workbench.texteditor"/>
<import plugin="org.eclipse.ltk.core.refactoring"/>
<import plugin="org.eclipse.jdt.ui"/>
<import plugin="org.eclipse.core.filebuffers"/>
</requires>
<plugin
id="com.alibaba.smartfox.eclipse.plugin"
download-size="0"
install-size="0"
version="0.0.0"/>
</feature>
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.feature/pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.alibaba.smartfox.eclipse</groupId>
<artifactId>smartfox-eclipse</artifactId>
<version>2.0.1-SNAPSHOT</version>
</parent>
<artifactId>com.alibaba.smartfox.eclipse.feature</artifactId>
<packaging>eclipse-feature</packaging>
<inceptionYear>2017</inceptionYear>
</project>
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/META-INF/MANIFEST.MF
================================================
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: com.alibaba.smartfox.eclipse.plugin
Bundle-SymbolicName: com.alibaba.smartfox.eclipse.plugin;singleton:=true
Bundle-Version: 2.0.1.qualifier
Bundle-Activator: com.alibaba.smartfox.eclipse.SmartfoxActivator
Bundle-Vendor: Alibaba
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.jdt.core,
org.eclipse.ui.ide,
org.eclipse.ui.views,
org.eclipse.core.resources,
org.eclipse.jface.text,
org.eclipse.ui.workbench.texteditor,
org.eclipse.ltk.core.refactoring,
org.eclipse.jdt.ui,
org.eclipse.core.filebuffers,
org.eclipse.equinox.p2.core,
org.eclipse.equinox.p2.engine,
org.eclipse.equinox.p2.operations,
org.eclipse.equinox.p2.metadata.repository,
org.eclipse.equinox.p2.ui,
org.eclipse.equinox.p2.metadata
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: target/lib/antlr-runtime.jar,
target/lib/antlr4-runtime.jar,
target/lib/asm.jar,
target/lib/commons-io.jar,
target/lib/commons-lang3.jar,
target/lib/gson.jar,
target/lib/javacc.jar,
target/lib/jaxen.jar,
target/lib/jcommander.jar,
target/lib/log4j.jar,
target/lib/pmd-core.jar,
target/lib/pmd-java.jar,
target/lib/pmd-javascript.jar,
target/lib/pmd-vm.jar,
target/lib/rhino.jar,
target/lib/saxon-dom.jar,
target/lib/saxon.jar,
target/lib/p3c-pmd.jar,
target/lib/kotlin-stdlib.jar,
target/lib/statistics-client.jar,
target/lib/guava.jar,
target/classes/,
.
Bundle-Localization: plugin
Export-Package: com.alibaba.smartfox.eclipse,
com.alibaba.smartfox.eclipse.handler,
com.alibaba.smartfox.eclipse.job,
com.alibaba.smartfox.eclipse.marker,
com.alibaba.smartfox.eclipse.pmd,
com.alibaba.smartfox.eclipse.pmd.rule,
com.alibaba.smartfox.eclipse.ui,
com.alibaba.smartfox.eclipse.ui.pmd,
com.alibaba.smartfox.eclipse.util
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/build.properties
================================================
bin.includes = .,\
META-INF/,\
plugin.xml,\
icons/,\
target/lib/
src.includes = icons/,\
META-INF/,\
plugin.xml,\
messages.properties,\
target/lib/,\
src/main/kotlin,\
pom.xml
source.. = src/main/java/,src/main/resources
output.. = target/classes/
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/plugin.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
id="SmartFoxViews"
name="SmartFoxViews"
point="org.eclipse.ui.views">
<category
name="SmartFoxViews"
id="com.alibaba.smartfox.eclipse.ui">
</category>
<view
name="P3C Results"
allowMultiple="false"
icon="icons/view/smartfox_logo.png"
category="com.alibaba.smartfox.eclipse.ui"
class="com.alibaba.smartfox.eclipse.ui.InspectionResultView"
id="com.alibaba.smartfox.eclipse.ui.InspectionResultView">
</view>
<view
name="Rule Detail"
allowMultiple="false"
icon="icons/view/smartfox_logo.png"
category="com.alibaba.smartfox.eclipse.ui"
class="com.alibaba.smartfox.eclipse.ui.RuleDetailView"
id="com.alibaba.smartfox.eclipse.ui.RuleDetailView">
</view>
<stickyView
location="LEFT"
id="com.alibaba.smartfox.eclipse.ui.RuleDetailView">
</stickyView>
</extension>
<extension point="org.eclipse.core.expressions.definitions">
<definition id="when.alibaba.analysis.is.active">
<or>
<with variable="activePartId">
<equals
value="org.eclipse.jdt.ui.PackageExplorer">
</equals>
</with>
<with variable="activePartId">
<equals
value="org.eclipse.ui.navigator.ProjectExplorer">
</equals>
</with>
<with variable="activeSite">
<adapt
type="org.eclipse.ui.IEditorSite">
</adapt>
</with>
</or>
</definition>
</extension>
<extension
point="org.eclipse.ui.commands">
<category
description="Alibaba Code Analysis"
id="alibaba.ui.commands"
name="Alibaba Command">
</category>
<command
categoryId="alibaba.ui.commands"
description="Alibaba Code Analysis"
id="com.alibaba.smartfox.eclipse.command.analysis"
name="Alibaba Code Analysis"/>
<command
categoryId="alibaba.ui.commands"
description="Alibaba Code Analysis"
id="com.alibaba.smartfox.eclipse.handler.SwitchLanguageHandler"
name="Switch Language"/>
</extension>
<extension
point="org.eclipse.ui.bindings">
<key
commandId="com.alibaba.smartfox.eclipse.command.analysis"
contextId="org.eclipse.ui.contexts.window"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="Ctrl+Shift+Alt+J">
</key>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="com.alibaba.smartfox.eclipse.handler.CodeAnalysisHandler"
commandId="com.alibaba.smartfox.eclipse.command.analysis">
<enabledWhen>
<reference
definitionId="when.alibaba.analysis.is.active">
</reference>
</enabledWhen>
</handler>
<handler
class="com.alibaba.smartfox.eclipse.handler.SwitchLanguageHandler"
commandId="com.alibaba.smartfox.eclipse.handler.SwitchLanguageHandler">
</handler>
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution allPopups="false"
locationURI="popup:org.eclipse.ui.popup.any">
<command
commandId="com.alibaba.smartfox.eclipse.command.analysis"
icon="icons/ali-ide-run.png"
label="Alibaba Code Guidelines"
style="push">
<visibleWhen
checkEnabled="false">
<reference definitionId="when.alibaba.analysis.is.active"/>
</visibleWhen>
</command>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
<toolbar
id="com.alibaba.smartfox.eclipse.plugin.toolbar3">
<command
commandId="com.alibaba.smartfox.eclipse.command.analysis"
icon="icons/ali-ide-run.png"
label="Alibaba Code Guidelines"
style="push"
tooltip="Alibaba Code Guidelines">
</command>
<command
commandId="com.alibaba.smartfox.eclipse.handler.SwitchLanguageHandler"
icon="icons/language.png"
label="Switch Language"
style="push"
tooltip="Switch Language">
</command>
</toolbar>
</menuContribution>
</extension>
<extension
id="p3cMarker"
name="P3C Violations"
point="org.eclipse.core.resources.markers">
<persistent value="false"/>
<super type="org.eclipse.core.resources.problemmarker"/>
</extension>
<extension point="org.eclipse.ui.ide.markerResolution">
<markerResolutionGenerator
markerType="com.alibaba.smartfox.eclipse.plugin.p3cMarker"
class="com.alibaba.smartfox.eclipse.QuickFixGenerator"/>
</extension>
<extension point="org.eclipse.ui.preferencePages">
<page name="Alibaba Code Analysis"
class="com.alibaba.smartfox.eclipse.ui.AllRulesPreferencePage"
id="com.alibaba.smartfox.eclipse.ui.AllRulesPreferencePage"/>
</extension>
</plugin>
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.alibaba.smartfox.eclipse</groupId>
<artifactId>smartfox-eclipse</artifactId>
<version>2.0.1-SNAPSHOT</version>
</parent>
<artifactId>com.alibaba.smartfox.eclipse.plugin</artifactId>
<packaging>eclipse-plugin</packaging>
<inceptionYear>2017</inceptionYear>
<properties>
<kotlin.compiler.incremental>false</kotlin.compiler.incremental>
</properties>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>com.alibaba.p3c</groupId>
<artifactId>p3c-pmd</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>20.0</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/kotlin</sourceDirectory>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<stripVersion>true</stripVersion>
<prependGroupId>false</prependGroupId>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<!-- exclude the apex (transitive) dependencies - we use the shaded
version instead -->
<excludeGroupIds>p2.eclipse-plugin,apex</excludeGroupIds>
<excludeArtifactIds>com.alibaba.smartfox.eclipse.plugin
</excludeArtifactIds>
<useRepositoryLayout>false</useRepositoryLayout>
</configuration>
<executions>
<execution>
<id>get-dependencies</id>
<phase>process-sources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-dependency-plugin
</artifactId>
<versionRange>[0,)</versionRange>
<goals>
<goal>copy-dependencies</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/QuickFix.kt
================================================
/*
* Copyright 1999-2017 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.smartfox.eclipse
import com.alibaba.p3c.pmd.lang.java.rule.constant.UpperEllRule
import com.alibaba.p3c.pmd.lang.java.rule.oop.EqualsAvoidNullRule
import com.alibaba.smartfox.eclipse.ui.InspectionResults
import com.alibaba.smartfox.eclipse.util.getRule
import com.google.common.io.Files
import org.eclipse.core.resources.IFile
import org.eclipse.core.resources.IMarker
import org.eclipse.core.runtime.NullProgressMonitor
import org.eclipse.ltk.core.refactoring.TextFileChange
import org.eclipse.text.edits.ReplaceEdit
import org.eclipse.ui.IMarkerResolution
import org.eclipse.ui.IMarkerResolutionGenerator
import java.nio.charset.Charset
/**
*
*
* @author caikang
* @date 2017/06/14
*/
class QuickFixGenerator : IMarkerResolutionGenerator {
override fun getResolutions(marker: IMarker): Array<IMarkerResolution> {
if (!marker.exists()) {
return emptyArray()
}
val rule = marker.getRule()
val quickFix = quickFixes[rule.name] ?: return emptyArray()
return arrayOf(quickFix)
}
companion object {
val quickFixes = mapOf(UpperEllRule::class.java.simpleName to UpperEllQuickFix,
EqualsAvoidNullRule::class.java.simpleName to EqualsAvoidNullQuickFix)
}
}
interface RunWithoutViewRefresh : IMarkerResolution {
fun run(marker: IMarker, refresh: Boolean)
override fun run(marker: IMarker) {
run(marker, true)
}
}
abstract class BaseQuickFix : RunWithoutViewRefresh {
override fun run(marker: IMarker, refresh: Boolean) {
if (!marker.exists()) {
return
}
val file = marker.resource as IFile
doRun(marker, file)
marker.delete()
if (refresh) {
InspectionResults.removeMarker(marker)
}
}
abstract fun doRun(marker: IMarker, file: IFile)
}
object UpperEllQuickFix : BaseQuickFix() {
override fun doRun(marker: IMarker, file: IFile) {
val offset = marker.getAttribute(IMarker.CHAR_START, 0)
val end = marker.getAttribute(IMarker.CHAR_END, 0)
val content = Files.toString(file.rawLocation.toFile(), Charset.forName(file.charset))
val replaceString = content.substring(offset, end + 1).replace("l", "L")
val edit = ReplaceEdit(offset, replaceString.length, replaceString)
val change = TextFileChange("", file)
change.edit = edit
change.perform(NullProgressMonitor())
}
override fun getLabel(): String {
return "Replace 'l' to 'L'."
}
}
object EqualsAvoidNullQuickFix : BaseQuickFix() {
val equalsName = ".equals("
override fun doRun(marker: IMarker, file: IFile) {
val offset = marker.getAttribute(IMarker.CHAR_START, 0)
val end = marker.getAttribute(IMarker.CHAR_END, 0)
val content = Files.toString(file.rawLocation.toFile(), Charset.forName(file.charset))
val string = content.substring(offset, end)
val list = string.split(equalsName).filterNotNull()
if (list.size != 2) {
return
}
val replace = "${list[1].substringBeforeLast(')')}$equalsName${list[0]})"
val edit = ReplaceEdit(offset, string.length, replace)
val change = TextFileChange("", file)
change.edit = edit
change.perform(NullProgressMonitor())
}
override fun getLabel(): String {
return "Flip equals."
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/SmartfoxActivator.kt
================================================
/*
* Copyright 1999-2017 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.smartfox.eclipse
import com.alibaba.p3c.pmd.I18nResources
import net.sourceforge.pmd.Rule
import net.sourceforge.pmd.RuleSetFactory
import net.sourceforge.pmd.RuleSets
import org.apache.log4j.Logger
import org.eclipse.core.runtime.IStatus
import org.eclipse.core.runtime.Status
import org.eclipse.jface.dialogs.MessageDialog
import org.eclipse.jface.resource.ImageDescriptor
import org.eclipse.swt.graphics.Image
import org.eclipse.swt.widgets.Display
import org.eclipse.ui.plugin.AbstractUIPlugin
import org.osgi.framework.BundleContext
import java.util.Locale
/**
* @author caikang
* @date 2017/06/14
*/
class SmartfoxActivator : AbstractUIPlugin() {
init {
aDefault = this
}
private val logger = Logger.getLogger(javaClass)!!
lateinit var ruleSets: RuleSets
private val localeKey = "p3c.locale"
lateinit var ruleMap: Map<String, Rule>
@Throws(Exception::class) override fun start(context: BundleContext) {
super.start(context)
I18nResources.changeLanguage(locale)
ruleSets = createRuleSets()
ruleMap = ruleSets.allRules.associateBy {
it.name
}
}
@Throws(Exception::class) override fun stop(context: BundleContext?) {
aDefault = null
super.stop(context)
}
fun getImage(key: String, iconPath: String = key): Image {
val registry = imageRegistry
var image: Image? = registry.get(key)
if (image == null) {
val descriptor = getImageDescriptor(iconPath)
registry.put(key, descriptor)
image = registry.get(key)
}
return image!!
}
val locale: String
get() {
val language = preferenceStore.getString(localeKey)
if (language.isNullOrBlank()) {
val lang = Locale.getDefault().language
return if (lang != Locale.ENGLISH.language && lang != Locale.CHINESE.language) {
Locale.ENGLISH.language
} else Locale.getDefault().language
}
return language
}
fun toggleLocale() {
val lang = if (Locale.ENGLISH.language == locale) Locale.CHINESE.language else Locale.ENGLISH.language
preferenceStore.setValue(localeKey, lang)
}
fun getRule(rule: String): Rule {
return ruleMap[rule]!!
}
fun showError(message: String, t: Throwable) {
logError(message, t)
Display.getDefault().syncExec {
MessageDialog.openError(Display.getCurrent().activeShell, "错误", message + "\n" + t.toString())
}
}
fun logError(message: String, t: Throwable) {
log.log(Status(IStatus.ERROR, bundle.symbolicName, 0, message + t.message, t))
logger.error(message, t)
}
fun logError(status: IStatus) {
log.log(status)
logger.error(status.message, status.exception)
}
fun logInformation(message: String) {
log.log(Status(IStatus.INFO, bundle.symbolicName, 0, message, null))
}
fun logWarn(message: String) {
log.log(Status(IStatus.WARNING, bundle.symbolicName, 0, message, null))
}
companion object {
// The plug-in ID
val PLUGIN_ID = "com.alibaba.smartfox.eclipse.plugin"
var aDefault: SmartfoxActivator? = null
private set
val instance: SmartfoxActivator get() = aDefault!!
fun getImageDescriptor(path: String): ImageDescriptor {
return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, path)
}
fun createRuleSets(): RuleSets {
val ruleSetFactory = RuleSetFactory()
return ruleSetFactory.createRuleSets("java-ali-pmd,vm-ali-other")
}
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/handler/CodeAnalysisHandler.kt
================================================
/*
* Copyright 1999-2017 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.smartfox.eclipse.handler
import com.alibaba.smartfox.eclipse.job.CodeAnalysis.processResources
import com.alibaba.smartfox.eclipse.message.P3cBundle
import com.google.common.collect.Sets
import org.apache.log4j.Logger
import org.eclipse.core.commands.AbstractHandler
import org.eclipse.core.commands.ExecutionEvent
import org.eclipse.core.commands.ExecutionException
import org.eclipse.core.resources.IFile
import org.eclipse.core.resources.IResource
import org.eclipse.core.resources.IResourceVisitor
import org.eclipse.core.runtime.IAdaptable
import org.eclipse.jface.viewers.IStructuredSelection
import org.eclipse.ui.IFileEditorInput
import org.eclipse.ui.IWorkingSet
import org.eclipse.ui.commands.IElementUpdater
import org.eclipse.ui.handlers.HandlerUtil
import org.eclipse.ui.menus.UIElement
import org.eclipse.ui.part.EditorPart
import org.eclipse.ui.part.ViewPart
/**
* @author caikang
* @date 2016/12/27
*/
open class CodeAnalysisHandler : AbstractHandler(), IElementUpdater {
override fun updateElement(element: UIElement, parameters: MutableMap<Any?, Any?>?) {
val text = P3cBundle.getMessage("com.alibaba.smartfox.eclipse.handler.CodeAnalysisHandler")
element.setText(text)
element.setTooltip(text)
}
@Throws(ExecutionException::class)
override fun execute(executionEvent: ExecutionEvent): Any? {
val selection = HandlerUtil.getCurrentSelectionChecked(executionEvent)
val part = HandlerUtil.getActivePart(executionEvent)
if (part is ViewPart) {
if (selection is IStructuredSelection) {
processForMutiFiles(selection)
}
} else if (part is EditorPart) {
val editorInput = HandlerUtil.getActiveEditorInput(executionEvent)
if (editorInput is IFileEditorInput) {
processResources(setOf(editorInput.file))
}
}
return null
}
private fun processForMutiFiles(selection: IStructuredSelection) {
val resources = getSelectionResources(selection)
processResources(resources)
}
private fun getSelectionResources(selection: IStructuredSelection): MutableSet<IResource> {
val resources = mutableSetOf<IResource>()
selection.toList().forEach {
when (it) {
is IWorkingSet -> it.elements.mapTo(resources) { it.getAdapter(IResource::class.java) as IResource }
is IAdaptable -> {
val file = it.getAdapter(IResource::class.java) as? IResource ?: return@forEach
resources.add(file)
}
else -> log.warn("The selected object is not adaptable : ${it.toString()}")
}
}
return resources
}
companion object {
private val log = Logger.getLogger(CodeAnalysisHandler::class.java)
}
}
class FileCollectVisitor : IResourceVisitor {
val fileSet = Sets.newLinkedHashSet<IFile>()!!
override fun visit(resource: IResource?): Boolean {
if (resource == null) {
return false
}
val file = resource.getAdapter(IFile::class.java) as? IFile ?: return true
if (file.exists() && (file.fileExtension == "java" || file.fileExtension == "vm")) {
fileSet.add(file)
}
return false
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/handler/SwitchLanguageHandler.kt
================================================
/*
* Copyright 1999-2017 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.smartfox.eclipse.handler
import com.alibaba.smartfox.eclipse.SmartfoxActivator
import com.alibaba.smartfox.eclipse.message.P3cBundle
import org.eclipse.core.commands.AbstractHandler
import org.eclipse.core.commands.ExecutionEvent
import org.eclipse.jface.dialogs.MessageDialog
import org.eclipse.ui.PlatformUI
import org.eclipse.ui.commands.IElementUpdater
import org.eclipse.ui.menus.UIElement
/**
*
*
* @author caikang
* @date 2017/06/21
*/
class SwitchLanguageHandler : AbstractHandler(), IElementUpdater {
val handlerKey = "com.alibaba.smartfox.eclipse.handler.SwitchLanguageHandler"
val textKey = "$handlerKey.text.cur_"
override fun execute(executionEvent: ExecutionEvent): Any? {
SmartfoxActivator.instance.toggleLocale()
if (!MessageDialog.openConfirm(null, "Tips",
P3cBundle.getMessage("$handlerKey.success.${SmartfoxActivator.instance.locale}"))) {
return null
}
PlatformUI.getWorkbench().restart()
return null
}
override fun updateElement(element: UIElement, parameters: MutableMap<Any?, Any?>?) {
val text = P3cBundle.getMessage("$textKey${SmartfoxActivator.instance.locale}")
element.setText(text)
element.setTooltip(text)
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/job/CodeAnalysis.kt
================================================
/*
* Copyright 1999-2017 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.smartfox.eclipse.job
import com.alibaba.p3c.pmd.lang.java.util.GeneratedCodeUtils
import com.alibaba.smartfox.eclipse.SmartfoxActivator
import com.alibaba.smartfox.eclipse.handler.CodeAnalysisHandler
import com.alibaba.smartfox.eclipse.handler.FileCollectVisitor
import com.alibaba.smartfox.eclipse.ui.InspectionResultView
import com.alibaba.smartfox.eclipse.ui.InspectionResults
import com.alibaba.smartfox.eclipse.ui.MarkerViolation
import com.alibaba.smartfox.eclipse.util.MarkerUtil
import com.google.common.io.Files
import net.sourceforge.pmd.PMDConfiguration
import net.sourceforge.pmd.PMDException
import net.sourceforge.pmd.Report
import net.sourceforge.pmd.RuleContext
import net.sourceforge.pmd.RuleViolation
import net.sourceforge.pmd.SourceCodeProcessor
import org.apache.log4j.Logger
import org.eclipse.core.resources.IFile
import org.eclipse.core.resources.IResource
import org.eclipse.core.runtime.IProgressMonitor
import org.eclipse.core.runtime.IStatus
import org.eclipse.core.runtime.Status
import org.eclipse.core.runtime.SubMonitor
import org.eclipse.core.runtime.jobs.Job
import java.io.IOException
import java.io.StringReader
import java.nio.charset.Charset
/**
*
*
* @author caikang
* @date 2017/06/14
*/
object CodeAnalysis {
private val log = Logger.getLogger(CodeAnalysisHandler::class.java)
fun processResources(resources: Set<IResource>) {
InspectionResultView.activeViews()
val job = object : Job("P3C Code Analysis") {
override fun run(monitor: IProgressMonitor): IStatus {
val fileVisitor = FileCollectVisitor()
monitor.setTaskName("Collect files")
resources.forEach {
if (monitor.isCanceled) {
return@run Status.CANCEL_STATUS
}
if (it.isAccessible) {
it.accept(fileVisitor)
}
}
if (monitor.isCanceled) {
return Status.CANCEL_STATUS
}
val subMonitor = SubMonitor.convert(monitor, "Analysis files", fileVisitor.fileSet.size)
monitor.setTaskName("Analysis files")
fileVisitor.fileSet.forEach { iFile ->
if (monitor.isCanceled) {
return@run Status.CANCEL_STATUS
}
MarkerUtil.removeAllMarkers(iFile)
monitor.subTask(iFile.fullPath.toPortableString())
val markers = processFileToMakers(iFile, monitor)
subMonitor.newChild(1)
InspectionResults.updateFileViolations(iFile, markers)
}
return Status.OK_STATUS
}
}
job.apply {
isUser = true
isSystem = false
priority = Job.INTERACTIVE
rule = P3cMutex
schedule()
}
}
fun processFileToMakers(file: IFile, monitor: IProgressMonitor): List<MarkerViolation> {
file.refreshLocal(IResource.DEPTH_ZERO, monitor)
val ruleViolations = processFile(file)
MarkerUtil.removeAllMarkers(file)
return ruleViolations.map {
MarkerViolation(MarkerUtil.addMarker(file, it), it)
}
}
private fun processFile(file: IFile): List<RuleViolation> {
val configuration = PMDConfiguration()
configuration.setSourceEncoding(file.charset ?: Charsets.UTF_8.name())
configuration.inputPaths = file.fullPath.toPortableString()
val ctx = RuleContext()
ctx.setAttribute("eclipseFile", file)
val niceFileName = configuration.inputPaths
val report = Report.createReport(ctx, niceFileName)
SmartfoxActivator.instance.ruleSets.start(ctx)
val processor = SourceCodeProcessor(configuration)
try {
ctx.languageVersion = null
val content = Files.toString(file.rawLocation.toFile(), Charset.forName(file.charset))
if (!GeneratedCodeUtils.isGenerated(content)) {
processor.processSourceCode(StringReader(content), SmartfoxActivator.instance.ruleSets, ctx)
}
} catch (pmde: PMDException) {
log.debug("Error while processing file: " + niceFileName, pmde.cause)
report.addError(Report.ProcessingError(pmde, niceFileName))
} catch (ioe: IOException) {
log.error("Unable to read source file: " + niceFileName, ioe)
} catch (re: RuntimeException) {
log.error("RuntimeException while processing file: " + niceFileName, re)
} finally {
SmartfoxActivator.instance.ruleSets.end(ctx)
}
return report.toList()
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/job/P3cMutex.kt
================================================
/*
* Copyright 1999-2017 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.smartfox.eclipse.job
import org.eclipse.core.runtime.jobs.ISchedulingRule
/**
*
*
* @author caikang
* @date 2017/06/14
*/
object P3cMutex : ISchedulingRule {
override fun contains(rule: ISchedulingRule?): Boolean {
return isConflicting(rule)
}
override fun isConflicting(rule: ISchedulingRule?): Boolean {
return rule == this
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/message/P3cBundle.kt
================================================
/*
* Copyright 1999-2017 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.smartfox.eclipse.message
import com.alibaba.p3c.pmd.I18nResources
import com.alibaba.smartfox.eclipse.SmartfoxActivator
import java.util.Locale
import java.util.ResourceBundle
/**
*
*
* @author caikang
* @date 2017/06/20
*/
object P3cBundle {
private val resourceBundle = ResourceBundle.getBundle("messages.P3cBundle",
Locale(SmartfoxActivator.instance.locale), I18nResources.XmlControl())
fun getMessage(key: String): String {
return resourceBundle.getString(key)
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/pmd/RulePriority.kt
================================================
/*
* Copyright 1999-2017 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.smartfox.eclipse.pmd
enum class RulePriority(val priority: Int, val title: String) {
Blocker(1, "Blocker"), Critical(2, "Critical"), Major(3, "Major");
override fun toString(): String {
return title
}
companion object {
fun valueOf(priority: Int): RulePriority {
try {
return RulePriority.values()[priority - 1]
} catch (e: ArrayIndexOutOfBoundsException) {
return Major
}
}
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/pmd/rule/AbstractEclipseRule.kt
================================================
/*
* Copyright 1999-2017 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.smartfox.eclipse.pmd.rule
import com.alibaba.smartfox.eclipse.message.P3cBundle
import net.sourceforge.pmd.Rule
import net.sourceforge.pmd.RuleContext
import net.sourceforge.pmd.RuleViolation
import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit
import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule
import org.eclipse.core.resources.IFile
import org.eclipse.core.runtime.NullProgressMonitor
import org.eclipse.jdt.core.ICompilationUnit
import org.eclipse.jdt.core.IProblemRequestor
import org.eclipse.jdt.core.JavaCore
import org.eclipse.jdt.core.JavaModelException
import org.eclipse.jdt.core.WorkingCopyOwner
import org.eclipse.jdt.core.compiler.IProblem
import org.eclipse.jdt.core.dom.ASTNode
import org.eclipse.jdt.core.dom.ASTVisitor
import org.eclipse.jdt.core.dom.CompilationUnit
import java.util.MissingResourceException
/**
* @author caikang
* @date 2016/12/26
*/
abstract class AbstractEclipseRule : AbstractJavaRule() {
open fun getErrorMessage(): String {
return message
}
override fun visit(node: ASTCompilationUnit, data: Any): Any? {
val result = super.visit(node, data)
val ruleContext = data as RuleContext
val file = ruleContext.getAttribute("eclipseFile") as? IFile ?: return result
val compilationUnit = JavaCore.createCompilationUnitFrom(file) ?: return data
try {
val requestor = object : IProblemRequestor {
override fun acceptProblem(problem: IProblem) {}
override fun beginReporting() {}
override fun endReporting() {}
override fun isActive(): Boolean {
return true
}
}
val workingCopy = compilationUnit.getWorkingCopy(null)
val ast = workingCopy.reconcile(JLS8, ICompilationUnit.FORCE_PROBLEM_DETECTION
or ICompilationUnit.ENABLE_BINDINGS_RECOVERY or ICompilationUnit.ENABLE_STATEMENTS_RECOVERY,
object : WorkingCopyOwner() {
override fun getProblemRequestor(workingCopy: ICompilationUnit?): IProblemRequestor {
return requestor
}
}, NullProgressMonitor()) ?: return data
ast.accept(getVisitor(ast, ruleContext))
} catch (e: JavaModelException) {
throw RuntimeException(e)
}
return data
}
override fun setDescription(description: String?) {
try {
super.setDescription(P3cBundle.getMessage(description ?: ""))
} catch (e: MissingResourceException) {
super.setMessage(description)
}
}
override fun setMessage(message: String) {
try {
super.setMessage(P3cBundle.getMessage(message))
} catch (e: MissingResourceException) {
super.setMessage(message)
}
}
protected abstract fun getVisitor(ast: CompilationUnit, ruleContext: RuleContext): ASTVisitor
internal fun addRuleViolation(ruleContext: RuleContext, ast: CompilationUnit, nodeInfo: NodeInfo) {
val rule = this
val ruleViolation = object : RuleViolation {
override fun getRule(): Rule {
return rule
}
override fun getDescription(): String {
return getErrorMessage().trim { it <= ' ' }
}
override fun isSuppressed(): Boolean {
return false
}
override fun getFilename(): String {
return ruleContext.sourceCodeFilename
}
override fun getBeginLine(): Int {
return ast.getLineNumber(nodeInfo.startPosition)
}
override fun getBeginColumn(): Int {
return ast.getColumnNumber(nodeInfo.startPosition)
}
override fun getEndLine(): Int {
return ast.getLineNumber(nodeInfo.endPosition)
}
override fun getEndColumn(): Int {
return ast.getColumnNumber(nodeInfo.endPosition)
}
override fun getPackageName(): String? {
return nodeInfo.packageName
}
override fun getClassName(): String? {
return nodeInfo.className
}
override fun getMethodName(): String? {
return nodeInfo.methodName
}
override fun getVariableName(): String? {
return nodeInfo.variableName
}
override fun toString(): String {
return rule.toString()
}
}
ruleContext.report.addRuleViolation(ruleViolation)
}
protected fun violation(rc: RuleContext, node: ASTNode, ast: CompilationUnit) {
val nodeInfo = NodeInfo()
nodeInfo.className = ast.javaElement.elementName
nodeInfo.packageName = ast.`package`.name.fullyQualifiedName
nodeInfo.startPosition = node.startPosition
nodeInfo.endPosition = node.startPosition + node.length
addRuleViolation(rc, ast, nodeInfo)
}
inner class NodeInfo {
internal var packageName: String? = null
internal var className: String? = null
internal var methodName: String? = null
internal var variableName: String? = null
internal var startPosition: Int = 0
internal var endPosition: Int = 0
}
companion object {
val JLS8 = 8
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/pmd/rule/AvoidAccessStaticViaInstanceRule.kt
================================================
/*
* Copyright 1999-2017 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.smartfox.eclipse.pmd.rule
import net.sourceforge.pmd.RuleContext
import org.eclipse.jdt.core.dom.ASTVisitor
import org.eclipse.jdt.core.dom.ClassInstanceCreation
import org.eclipse.jdt.core.dom.CompilationUnit
import org.eclipse.jdt.core.dom.FieldAccess
import org.eclipse.jdt.core.dom.IVariableBinding
import org.eclipse.jdt.core.dom.MethodInvocation
import org.eclipse.jdt.core.dom.Modifier
import org.eclipse.jdt.core.dom.QualifiedName
import org.eclipse.jdt.core.dom.SimpleName
import org.eclipse.jdt.core.dom.VariableDeclarationFragment
/**
* @author caikang
* @date 2016/12/27
*/
class AvoidAccessStaticViaInstanceRule : AbstractEclipseRule() {
override fun getVisitor(ast: CompilationUnit, ruleContext: RuleContext): ASTVisitor {
return object : ASTVisitor() {
override fun visit(node: QualifiedName?): Boolean {
val parent = node!!.parent
if (parent !is MethodInvocation && parent !is VariableDeclarationFragment) {
return false
}
val name = node.name
val binding = name.resolveBinding()
if (binding !is IVariableBinding || binding.getModifiers() and Modifier.STATIC == 0) {
return true
}
val qualifier = node.qualifier
val typeBinding = qualifier.resolveTypeBinding()
if (qualifier.isSimpleName) {
when (parent) {
is MethodInvocation -> {
val methodBinding = parent.resolveMethodBinding()
val methodTypeBinding = methodBinding.declaringClass
if (methodBinding.modifiers and Modifier.STATIC != 0
&& qualifier.fullyQualifiedName != methodTypeBinding.name
&& methodTypeBinding == typeBinding && binding.name != typeBinding.name) {
violation(ruleContext, parent, ast)
return false
}
}
else -> {
}
}
if (typeBinding.name != qualifier.fullyQualifiedName) {
violation(ruleContext, node, ast)
return false
}
}
if (qualifier.isQualifiedName) {
val qualifiedName = qualifier as QualifiedName
if (typeBinding.name != qualifiedName.name.identifier) {
violation(ruleContext, node, ast)
return false
}
}
return true
}
override fun visit(node: FieldAccess): Boolean {
val variableBinding = node.resolveFieldBinding() ?: return false
if (variableBinding.modifiers and Modifier.STATIC == 0) {
return true
}
if (node.expression is ClassInstanceCreation) {
violation(ruleContext, node, ast)
return true
}
return true
}
override fun visit(node: MethodInvocation?): Boolean {
val methodBinding = node?.resolveMethodBinding() ?: return false
if (methodBinding.modifiers and Modifier.STATIC == 0) {
return true
}
if (node.expression is ClassInstanceCreation) {
violation(ruleContext, node, ast)
return true
}
val expression = node.expression
if (expression is SimpleName && expression.identifier != expression.resolveTypeBinding().name) {
violation(ruleContext, node, ast)
return true
}
return true
}
}
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/pmd/rule/AvoidUseDeprecationRule.kt
================================================
/*
* Copyright 1999-2017 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.smartfox.eclipse.pmd.rule
import net.sourceforge.pmd.RuleContext
import org.eclipse.jdt.core.dom.ASTVisitor
import org.eclipse.jdt.core.dom.ClassInstanceCreation
import org.eclipse.jdt.core.dom.CompilationUnit
import org.eclipse.jdt.core.dom.FieldAccess
import org.eclipse.jdt.core.dom.IVariableBinding
import org.eclipse.jdt.core.dom.ImportDeclaration
import org.eclipse.jdt.core.dom.MethodInvocation
import org.eclipse.jdt.core.dom.Modifier
import org.eclipse.jdt.core.dom.QualifiedName
import org.eclipse.jdt.core.dom.TypeDeclaration
import org.eclipse.jdt.core.dom.VariableDeclarationFragment
/**
* @author caikang
* @date 2016/12/27
*/
class AvoidUseDeprecationRule : AbstractEclipseRule() {
override fun getVisitor(ast: CompilationUnit, ruleContext: RuleContext): ASTVisitor {
return object : ASTVisitor() {
override fun visit(node: ImportDeclaration?): Boolean {
if (node!!.resolveBinding() != null && node.resolveBinding().isDeprecated) {
violation(ruleContext, node, ast)
}
return true
}
override fun visit(node: QualifiedName?): Boolean {
if (node!!.parent !is MethodInvocation && node.parent !is VariableDeclarationFragment) {
return false
}
val name = node.name
val binding = name.resolveBinding()
if (binding !is IVariableBinding || binding.getModifiers() and Modifier.STATIC == 0) {
return true
}
if (binding.isDeprecated()) {
violation(ruleContext, node, ast)
return false
}
val qualifier = node.qualifier
val typeBinding = qualifier.resolveTypeBinding()
if (typeBinding.isDeprecated) {
violation(ruleContext, node, ast)
return false
}
return true
}
override fun visit(node: TypeDeclaration?): Boolean {
val superClass = node!!.superclassType
if (superClass != null && superClass.resolveBinding().isDeprecated) {
violation(ruleContext, node, ast)
return true
}
val interfaces = node.resolveBinding().interfaces
for (tb in interfaces) {
if (tb.isDeprecated) {
violation(ruleContext, node, ast)
return true
}
}
return true
}
override fun visit(node: FieldAccess?): Boolean {
val variableBinding = node!!.resolveFieldBinding() ?: return false
if (variableBinding.isDeprecated) {
violation(ruleContext, node, ast)
}
return true
}
override fun visit(node: MethodInvocation): Boolean {
val methodBinding = node.resolveMethodBinding() ?: return false
if (methodBinding.isDeprecated) {
violation(ruleContext, node, ast)
}
return true
}
override fun visit(node: ClassInstanceCreation?): Boolean {
if (node!!.resolveTypeBinding().isDeprecated) {
violation(ruleContext, node, ast)
}
return true
}
}
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/pmd/rule/MapOrSetKeyShouldOverrideHashCodeEqualsRule.kt
================================================
/*
* Copyright 1999-2017 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.smartfox.eclipse.pmd.rule
import net.sourceforge.pmd.RuleContext
import org.eclipse.jdt.core.dom.ASTVisitor
import org.eclipse.jdt.core.dom.CompilationUnit
import org.eclipse.jdt.core.dom.ITypeBinding
import org.eclipse.jdt.core.dom.MethodInvocation
import org.eclipse.jdt.core.dom.VariableDeclarationStatement
/**
* @author zenghou.fw
* @date 2016/12/27
*/
class MapOrSetKeyShouldOverrideHashCodeEqualsRule : AbstractEclipseRule() {
val methodEquals = "equals"
val methodHashCode = "hashCode"
val methodAdd = "add"
val methodPut = "put"
private val skipJdkPackageJava = "java."
private val skipJdkPackageJavax = "javax."
override fun getVisitor(ast: CompilationUnit, ruleContext: RuleContext): ASTVisitor {
return object : ASTVisitor() {
override fun visit(node: VariableDeclarationStatement): Boolean {
if (!node.type.isParameterizedType) {
return true
}
val typeBinding = node.type.resolveBinding()
if (isSet(typeBinding) || isMap(typeBinding)) {
val argumentTypes = typeBinding.typeArguments
if (argumentTypes != null && argumentTypes.isNotEmpty()) {
if (!isOverrideEqualsAndHashCode(argumentTypes[0])) {
violation(ruleContext, node, ast)
return false
}
}
}
return true
}
override fun visit(node: MethodInvocation): Boolean {
val methodBinding = node.resolveMethodBinding() ?: return false
val callerType = methodBinding.declaringClass
if (methodAdd == methodBinding.name) {
if (!isSet(callerType)) {
return true
}
val parameterTypes = methodBinding.parameterTypes
if (parameterTypes != null && parameterTypes.isNotEmpty()) {
if (!isOverrideEqualsAndHashCode(parameterTypes[0])) {
violation(ruleContext, node, ast)
return false
}
}
return true
}
if (methodPut == methodBinding.name) {
if (!isMap(callerType)) {
return true
}
val parameterTypes = methodBinding.parameterTypes
if (parameterTypes != null && parameterTypes.isNotEmpty()) {
if (!isOverrideEqualsAndHashCode(parameterTypes[0])) {
violation(ruleContext, node, ast)
return false
}
}
}
return true
}
private fun isOverrideEqualsAndHashCode(genericType: ITypeBinding): Boolean {
val skip = genericType.isEnum || genericType.isInterface || genericType.isArray
|| genericType.isTypeVariable || genericType.isWildcardType
|| genericType.qualifiedName?.startsWith(skipJdkPackageJava) ?: false
|| genericType.qualifiedName?.startsWith(skipJdkPackageJavax) ?: false
// skip
if (skip) {
return true
}
val methodBindings = genericType.declaredMethods ?: return false
val overrideCount = methodBindings.asSequence().filter {
//find equals(Object o) and hashCode() with @Override
methodEquals == it.name || methodHashCode == it.name
}.filter {
when (it.name) {
methodEquals -> {
val parameterTypes = it.parameterTypes
parameterTypes != null && parameterTypes.isNotEmpty()
&& Object::class.java.name == parameterTypes[0].qualifiedName
}
methodHashCode -> {
val parameterTypes = it.parameterTypes
parameterTypes == null || parameterTypes.isEmpty()
}
else -> false
}
}.count()
return overrideCount == 2
}
private fun isSet(typeBinding: ITypeBinding): Boolean {
return java.util.Set::class.java.name == typeBinding.binaryName
}
private fun isMap(typeBinding: ITypeBinding): Boolean {
return java.util.Map::class.java.name == typeBinding.binaryName
}
}
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/pmd/rule/MissingOverrideAnnotationRule.kt
================================================
/*
* Copyright 1999-2017 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.smartfox.eclipse.pmd.rule
import com.alibaba.smartfox.eclipse.message.P3cBundle
import net.sourceforge.pmd.RuleContext
import org.eclipse.jdt.core.dom.ASTVisitor
import org.eclipse.jdt.core.dom.CompilationUnit
import org.eclipse.jdt.core.dom.MethodDeclaration
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding
import java.util.Arrays
import javax.annotation.Generated
/**
* @author caikang
* @date 2016/12/24
*/
class MissingOverrideAnnotationRule : AbstractEclipseRule() {
override fun getErrorMessage(): String {
return P3cBundle.getMessage("rule.standalone.MissingOverrideAnnotationRule.error")
}
override fun getVisitor(ast: CompilationUnit, ruleContext: RuleContext): ASTVisitor {
return MissingOverrideVisitor(ast, ruleContext)
}
private inner class MissingOverrideVisitor(private val ast: CompilationUnit,
private val ruleContext: RuleContext) : ASTVisitor() {
override fun visit(node: MethodDeclaration?): Boolean {
val methodBinding = node!!.resolveBinding()
val declaringClass = methodBinding.declaringClass ?: return super.visit(node)
if (declaringClass.isInterface) {
return super.visit(node)
}
val abs = methodBinding.annotations
if (abs.any {
Override::class.java.canonicalName == it.annotationType.binaryName
}) {
return super.visit(node)
}
try {
val field = methodBinding.javaClass.getDeclaredField("binding")
field.isAccessible = true
val internalBinding = field.get(methodBinding) as MethodBinding
if (internalBinding.isStatic || !(internalBinding.isImplementing || internalBinding.isOverriding)
|| isGenerated(internalBinding)) {
return super.visit(node)
}
violation(ruleContext, node, ast)
} catch (e: Exception) {
e.printStackTrace()
}
return super.visit(node)
}
/**
* skip @Override check for generated code by lombok
* @param internalBinding
* @return
*/
private fun isGenerated(internalBinding: MethodBinding): Boolean {
val annotationBindings = internalBinding.annotations ?: return false
return annotationBindings.any {
it.annotationType != null && Arrays.equals(Generated::class.java.name.toCharArray(),
it.annotationType.readableName())
}
}
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/AllRulesPreferencePage.kt
================================================
/*
* Copyright 1999-2017 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.smartfox.eclipse.ui
import org.eclipse.jface.preference.PreferencePage
import org.eclipse.swt.widgets.Composite
import org.eclipse.swt.widgets.Control
import org.eclipse.ui.IWorkbench
import org.eclipse.ui.IWorkbenchPreferencePage
/**
*
* @author caikang
* @date 2017/09/01
*/
class AllRulesPreferencePage : PreferencePage(), IWorkbenchPreferencePage {
override fun init(parent: IWorkbench?) {
}
override fun createContents(parent: Composite): Control {
return AllRulesView(parent).content
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/AllRulesView.kt
================================================
/*
* Copyright 1999-2017 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.smartfox.eclipse.ui
import com.alibaba.smartfox.eclipse.SmartfoxActivator
import org.eclipse.swt.SWT
import org.eclipse.swt.layout.FillLayout
import org.eclipse.swt.widgets.Composite
import org.eclipse.swt.widgets.List
/**
*
* @author caikang
* @date 2017/09/01
*/
class AllRulesView(parent: Composite) {
val content = Composite(parent, SWT.NONE)
private val ruleList = SmartfoxActivator.instance.ruleSets.allRules.toList()
init {
content.layout = FillLayout()
val list = List(content, SWT.BORDER or SWT.SINGLE or SWT.V_SCROLL or SWT.PUSH or SWT.H_SCROLL)
ruleList.forEach {
list.add(it.message)
}
val ruleDetail = RuleDetailComposite(content, SWT.PUSH)
list.addListener(SWT.Selection) {
val index = list.selectionIndex
val rule = ruleList.getOrNull(index) ?: return@addListener
ruleDetail.refresh(rule)
}
list.select(0)
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/InspectionResultTreeContentProvider.kt
================================================
/*
* Copyright 1999-2017 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.smartfox.eclipse.ui
import org.eclipse.jface.viewers.ITreeContentProvider
import org.eclipse.jface.viewers.Viewer
/**
*
*
* @author caikang
* @date 2017/06/08
*/
object InspectionResultTreeContentProvider : ITreeContentProvider {
private lateinit var input: InspectionResults
override fun getParent(element: Any?): Any {
return input
}
override fun hasChildren(element: Any?): Boolean {
return element is InspectionResults || element is LevelViolations || element is RuleViolations
|| element is FileMarkers
}
override fun getChildren(parentElement: Any?): Array<Any> {
if (parentElement is InspectionResults) {
return parentElement.errors.toTypedArray()
}
if (parentElement is LevelViolations) {
return parentElement.rules.toTypedArray()
}
if (parentElement is RuleViolations) {
return parentElement.files.toTypedArray()
}
if (parentElement is FileMarkers) {
return parentElement.markers.toTypedArray()
}
return emptyArray()
}
override fun getElements(inputElement: Any?): Array<Any> {
return input.errors.toTypedArray()
}
override fun inputChanged(viewer: Viewer?, oldInput: Any?, newInput: Any?) {
if (newInput == null) {
return
}
this.input = newInput as InspectionResults
}
override fun dispose() {
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/InspectionResultTreeLabelProvider.kt
================================================
/*
* Copyright 1999-2017 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.smartfox.eclipse.ui
import com.alibaba.smartfox.eclipse.SmartfoxActivator
import com.alibaba.smartfox.eclipse.pmd.RulePriority
import org.eclipse.jface.viewers.LabelProvider
import org.eclipse.swt.graphics.Image
/**
*
*
* @author caikang
* @date 2017/06/08
*/
object InspectionResultTreeLabelProvider : LabelProvider() {
override fun getImage(element: Any?): Image? {
if (element is LevelViolations) {
val imageName = when (element.level) {
RulePriority.Blocker.title, RulePriority.Critical.title -> "${element.level}.gif".toLowerCase()
else -> "${element.level}.png".toLowerCase()
}
return SmartfoxActivator.instance.getImage("icons/view/$imageName")
}
if (element is FileMarkers) {
if (element.file.fullPath.toPortableString().endsWith("java")) {
return SmartfoxActivator.instance.getImage("icons/view/class_obj.png")
}
return SmartfoxActivator.instance.getImage("icons/view/file_obj.png")
}
return null
}
override fun getText(element: Any?): String {
if (element is LevelViolations) {
return "${element.level} (${element.count} Violations)"
}
if (element is RuleViolations) {
val rule = SmartfoxActivator.instance.getRule(element.rule)
return "${rule.message} (${element.count} Violations)"
}
if (element is FileMarkers) {
return element.file.fullPath.toPortableString().substringAfterLast("/") +
" (${element.markers.size} Violations)"
}
if (element is MarkerViolation) {
val desc = element.violation.description
return "$desc (at line ${element.violation.beginLine})"
}
return element.toString()
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/InspectionResultView.kt
================================================
/*
* Copyright 1999-2017 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.smartfox.eclipse.ui
import com.alibaba.smartfox.eclipse.SmartfoxActivator
import com.alibaba.smartfox.eclipse.job.P3cMutex
import com.alibaba.smartfox.eclipse.util.MarkerUtil
import org.eclipse.core.resources.IFile
import org.eclipse.core.resources.IMarker
import org.eclipse.core.runtime.IProgressMonitor
import org.eclipse.core.runtime.IStatus
import org.eclipse.core.runtime.Status
import org.eclipse.core.runtime.jobs.Job
import org.eclipse.jface.action.Action
import org.eclipse.jface.action.Separator
import org.eclipse.jface.util.OpenStrategy
import org.eclipse.jface.viewers.ISelection
import org.eclipse.jface.viewers.IStructuredSelection
import org.eclipse.jface.viewers.ITreeSelection
import org.eclipse.jface.viewers.TreeViewer
import org.eclipse.swt.SWT
import org.eclipse.swt.layout.FillLayout
import org.eclipse.swt.widgets.Composite
import org.eclipse.swt.widgets.Display
import org.eclipse.ui.IWorkbenchPage
import org.eclipse.ui.OpenAndLinkWithEditorHelper
import org.eclipse.ui.PartInitException
import org.eclipse.ui.PlatformUI
import org.eclipse.ui.ide.IDE
import org.eclipse.ui.ide.ResourceUtil
import org.eclipse.ui.internal.views.markers.MarkerSupportInternalUtilities
import org.eclipse.ui.part.ViewPart
import org.eclipse.ui.texteditor.ITextEditor
import java.util.HashSet
/**
*
*
* @author caikang
* @date 2017/06/08
*/
class InspectionResultView : ViewPart() {
lateinit var treeViewer: TreeViewer
private val quickFixAction = QuickFixAction(this)
override fun setFocus() {
treeViewer.control.setFocus()
}
override fun createPartControl(parent: Composite) {
parent.layout = FillLayout()
treeViewer = TreeViewer(parent, SWT.MULTI or SWT.H_SCROLL or SWT.V_SCROLL)
treeViewer.setUseHashlookup(true)
treeViewer.contentProvider = InspectionResultTreeContentProvider
treeViewer.labelProvider = InspectionResultTreeLabelProvider
treeViewer.input = InspectionResults
InspectionResults.view = this
addDoubleClickListener()
addSelectionChangedListener()
initToolBar()
addLinkWithEditorSupport()
site.selectionProvider = treeViewer
}
fun clear() {
InspectionResults.clear()
refreshView(InspectionResults)
}
fun refreshView(input: InspectionResults) {
Display.getDefault().asyncExec {
treeViewer.refresh(input, true)
contentDescription = input.contentDescription
}
}
private fun addSelectionChangedListener() {
treeViewer.addSelectionChangedListener inner@ {
val selection = it.selection as? IStructuredSelection ?: return@inner
val item = selection.firstElement ?: return@inner
val ruleDetailView = RuleDetailView.showAndGetView()
when (item) {
is MarkerViolation -> {
ruleDetailView.refresh(item.violation.rule)
quickFixAction.updateFileMarkers(listOf(FileMarkers(item.marker.resource as IFile, listOf(item))))
}
is FileMarkers -> {
ruleDetailView.refresh(item.markers.first().violation.rule)
quickFixAction.updateFileMarkers(listOf(item))
}
is RuleViolations -> {
ruleDetailView.refresh(SmartfoxActivator.instance.getRule(item.rule))
quickFixAction.updateFileMarkers(item.files)
}
else -> {
quickFixAction.updateFileMarkers(emptyList())
}
}
}
}
private fun initToolBar() {
val bars = viewSite.actionBars
val tm = bars.toolBarManager
val clearAction = object : Action("Clear Markers") {
override fun run() {
val job = object : Job("Clear Markers") {
override fun run(monitor: IProgressMonitor): IStatus {
if (monitor.isCanceled) {
Status.CANCEL_STATUS
}
clear()
return Status.OK_STATUS
}
}
job.rule = P3cMutex
job.schedule()
}
}
clearAction.imageDescriptor = SmartfoxActivator.getImageDescriptor("icons/actions/clear.png")
tm.add(Separator("Markers"))
tm.add(clearAction)
tm.add(Separator("FilterGroup"))
tm.add(quickFixAction)
}
private fun addLinkWithEditorSupport() {
object : OpenAndLinkWithEditorHelper(treeViewer) {
override fun activate(selection: ISelection) {
val currentMode = OpenStrategy.getOpenMethod()
try {
OpenStrategy.setOpenMethod(OpenStrategy.DOUBLE_CLICK)
openSelectedMarkers()
} finally {
OpenStrategy.setOpenMethod(currentMode)
}
}
override fun linkToEditor(selection: ISelection?) {
}
override fun open(selection: ISelection, activate: Boolean) {
val structured = selection as ITreeSelection
val element = structured.firstElement as? MarkerViolation ?: return
val page = site.page
if (element.marker.exists()) {
openMarkerInEditor(element.marker, page)
return
}
val file = element.marker.resource as IFile
val editor = IDE.openEditor(page, file) as ITextEditor
editor.selectAndReveal(MarkerUtil.getAbsoluteRange(file, element.violation).start, 0)
}
}
}
internal fun openSelectedMarkers() {
val markers = getOpenableMarkers()
for (marker in markers) {
val page = site.page
openMarkerInEditor(marker, page)
}
}
private fun getOpenableMarkers(): Array<IMarker> {
val structured = treeViewer.selection as ITreeSelection
val elements = structured.iterator()
val result = HashSet<IMarker>()
while (elements.hasNext()) {
val marker = elements.next() as? IMarker ?: return emptyArray()
result.add(marker)
}
return result.toTypedArray()
}
fun openMarkerInEditor(marker: IMarker?, page: IWorkbenchPage) {
val editor = page.activeEditor
if (editor != null) {
val input = editor.editorInput
val file = ResourceUtil.getFile(input)
if (file != null) {
if (marker!!.resource == file && OpenStrategy.activateOnOpen()) {
page.activate(editor)
}
}
}
if (marker != null && marker.resource is IFile) {
try {
IDE.openEditor(page, marker, OpenStrategy.activateOnOpen())
} catch (e: PartInitException) {
MarkerSupportInternalUtilities.showViewError(e)
}
}
}
private fun addDoubleClickListener() {
treeViewer.addDoubleClickListener({ event ->
val selection = event.selection
if (selection !is ITreeSelection || selection.size() != 1) {
return@addDoubleClickListener
}
val obj = selection.firstElement
if (treeViewer.isExpandable(obj)) {
treeViewer.setExpandedState(obj, !treeViewer.getExpandedState(obj))
}
})
}
companion object {
val viewId = "com.alibaba.smartfox.eclipse.ui.InspectionResultView"
fun activeViews() {
PlatformUI.getWorkbench().activeWorkbenchWindow.activePage.showView(viewId)
RuleDetailView.showAndGetView()
}
fun getView(): InspectionResultView {
return PlatformUI.getWorkbench().activeWorkbenchWindow.activePage.findView(viewId) as InspectionResultView
}
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/InspectionResults.kt
================================================
/*
* Copyright 1999-2017 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.smartfox.eclipse.ui
import com.alibaba.smartfox.eclipse.pmd.RulePriority
import com.alibaba.smartfox.eclipse.util.MarkerUtil
import org.eclipse.core.resources.IFile
import org.eclipse.core.resources.IMarker
/**
*
*
* @author caikang
* @date 2017/06/13
*/
object InspectionResults {
private val fileViolations = linkedMapOf<IFile, List<MarkerViolation>>()
var contentDescription = ""
val errors: List<LevelViolations>
get() {
val result = toLevelViolationList(fileViolations.values.flatten())
contentDescription = getContentDescription(result)
return result
}
lateinit var view: InspectionResultView
fun clear() {
fileViolations.forEach {
MarkerUtil.removeAllMarkers(it.key)
}
fileViolations.clear()
// update contentDescription
errors
}
private fun toLevelViolationList(markers: Collection<MarkerViolation>): List<LevelViolations> {
return markers.groupBy {
it.violation.rule.priority.priority
}.mapValues {
it.value.groupBy {
it.violation.rule.name
}.mapValues {
it.value.groupBy {
it.marker.resource as IFile
}.map {
FileMarkers(it.key, it.value)
}
}.map {
RuleViolations(it.key, it.value)
}
}.toSortedMap().map {
val level = RulePriority.valueOf(it.key).title
LevelViolations(level, it.value)
}
}
fun updateFileViolations(file: IFile, markers: List<MarkerViolation>) {
if (markers.isEmpty()) {
fileViolations.remove(file)
} else {
fileViolations[file] = markers
}
view.refreshView(this)
}
fun removeMarker(marker: IMarker) {
val file = marker.resource as IFile
val list = fileViolations[file] ?: return
val result = list.filter {
it.marker != marker
}
fileViolations[file] = result
marker.delete()
view.refreshView(this)
}
fun getContentDescription(errors: List<LevelViolations>): String {
val map = errors.associateBy {
it.level
}
return "${map[RulePriority.Blocker.title]?.count ?: 0} Blockers," +
"${map[RulePriority.Critical.title]?.count ?: 0} Criticals," +
"${map[RulePriority.Major.title]?.count ?: 0} Majors"
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/QuickFixAction.kt
================================================
/*
* Copyright 1999-2017 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.smartfox.eclipse.ui
import com.alibaba.p3c.pmd.lang.java.rule.flowcontrol.NeedBraceRule
import com.alibaba.smartfox.eclipse.RunWithoutViewRefresh
import com.alibaba.smartfox.eclipse.SmartfoxActivator
import com.alibaba.smartfox.eclipse.job.CodeAnalysis
import com.alibaba.smartfox.eclipse.job.P3cMutex
import com.alibaba.smartfox.eclipse.pmd.rule.MissingOverrideAnnotationRule
import com.alibaba.smartfox.eclipse.util.CleanUps
import com.alibaba.smartfox.eclipse.util.getResolution
import org.eclipse.core.runtime.IProgressMonitor
import org.eclipse.core.runtime.IStatus
import org.eclipse.core.runtime.Status
import org.eclipse.core.runtime.SubMonitor
import org.eclipse.core.runtime.jobs.Job
import org.eclipse.jface.action.Action
/**
*
*
* @author caikang
* @date 2017/06/14
*/
class QuickFixAction(val view: InspectionResultView) : Action("Quick Fix") {
init {
imageDescriptor = SmartfoxActivator.getImageDescriptor("icons/actions/quickfixBulb.png")
isEnabled = false
}
var markers = listOf<FileMarkers>()
fun updateFileMarkers(markers: List<FileMarkers>) {
this.markers = markers
isEnabled = enabled()
}
override fun run() {
if (markers.isEmpty()) {
return
}
runJob()
}
private fun runJob() {
val job = object : Job("Perform P3C Quick Fix") {
override fun run(monitor: IProgressMonitor): IStatus {
val subMonitor = SubMonitor.convert(monitor, markers.size)
monitor.setTaskName("Process File")
markers.forEach {
if (monitor.isCanceled) {
return@run Status.CANCEL_STATUS
}
monitor.subTask(it.file.name)
val childMonitor = subMonitor.newChild(1)
if (useCleanUpRefactoring()) {
CleanUps.fix(it.file, childMonitor)
} else {
it.markers.filter { it.marker.exists() }.forEach {
(it.marker.getResolution() as RunWithoutViewRefresh).run(it.marker, true)
}
}
val markers = CodeAnalysis.processFileToMakers(it.file, monitor)
InspectionResults.updateFileViolations(it.file, markers)
}
return Status.OK_STATUS
}
}
val outJob = object:Job("P3C Quick Fix Wait analysis finish"){
override fun run(monitor: IProgressMonitor?): IStatus {
job.schedule()
return Status.OK_STATUS
}
}
outJob.rule = P3cMutex
outJob.schedule()
}
fun enabled(): Boolean {
if (useCleanUpRefactoring()) {
return true
}
if (markers.isEmpty()) {
return false
}
val marker = markers.first().markers.first().marker
return marker.exists() && marker.getResolution() != null
}
private fun useCleanUpRefactoring(): Boolean {
if (markers.isEmpty()) {
return false
}
val ruleName = markers.first().markers.first().violation.rule.name
return ruleName == MissingOverrideAnnotationRule::class.java.simpleName
|| ruleName == NeedBraceRule::class.java.simpleName
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/RuleDetailComposite.kt
================================================
/*
* Copyright 1999-2017 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.smartfox.eclipse.ui
import com.alibaba.smartfox.eclipse.pmd.RulePriority
import com.alibaba.smartfox.eclipse.ui.pmd.ContentBuilder
import com.alibaba.smartfox.eclipse.ui.pmd.StringArranger
import net.sourceforge.pmd.Rule
import org.eclipse.swt.SWT
import org.eclipse.swt.custom.StyledText
import org.eclipse.swt.layout.FillLayout
import org.eclipse.swt.widgets.Composite
/**
*
* @author caikang
* @date 2017/09/01
*/
class RuleDetailComposite(parent: Composite, style: Int = SWT.NONE) {
private val viewField: StyledText
private val contentBuilder = ContentBuilder()
private val arranger = StringArranger(" ")
private val panel = Composite(parent, style)
init {
panel.layout = FillLayout()
viewField = StyledText(panel, SWT.BORDER or SWT.H_SCROLL or SWT.V_SCROLL)
viewField.wordWrap = true
viewField.tabs = 20
viewField.text = "Select a result item to show rule detail."
viewField.editable = false
}
fun refresh(rule: Rule) {
contentBuilder.clear()
viewField.text = ""
contentBuilder.addHeading("Name")
contentBuilder.addText(rule.name)
contentBuilder.addHeading("Severity")
contentBuilder.addText(RulePriority.valueOf(rule.priority.priority).title)
contentBuilder.addHeading("Message")
contentBuilder.addText(rule.message)
if (!rule.description.isNullOrBlank()) {
contentBuilder.addHeading("Description")
contentBuilder.addRawText(arranger.format(rule.description).toString())
}
val examples = rule.examples
if (examples.isEmpty()) {
contentBuilder.showOn(viewField)
return
}
contentBuilder.setLanguage(rule.language)
contentBuilder.addHeading("Examples")
contentBuilder.addText("")
for (example in rule.examples) {
contentBuilder.addCode(example.trim { it <= ' ' })
contentBuilder.addText("")
}
contentBuilder.showOn(viewField)
if (contentBuilder.hasLinks()) {
contentBuilder.addLinkHandler(viewField)
}
viewField.update()
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/RuleDetailView.kt
================================================
/*
* Copyright 1999-2017 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.smartfox.eclipse.ui
import com.alibaba.smartfox.eclipse.SmartfoxActivator
import net.sourceforge.pmd.Rule
import org.eclipse.jface.action.Action
import org.eclipse.jface.action.Separator
import org.eclipse.swt.SWT
import org.eclipse.swt.custom.ScrolledComposite
import org.eclipse.swt.layout.FillLayout
import org.eclipse.swt.widgets.Composite
import org.eclipse.swt.widgets.Display
import org.eclipse.swt.widgets.Shell
import org.eclipse.ui.IWorkbenchPage
import org.eclipse.ui.PlatformUI
import org.eclipse.ui.part.ViewPart
/**
*
*
* @author caikang
* @date 2017/06/12
*/
open class RuleDetailView : ViewPart() {
private lateinit var ruleDetailComposite: RuleDetailComposite
override fun setFocus() {
}
override fun createPartControl(parent: Composite) {
ruleDetailComposite = RuleDetailComposite(parent)
initToolBar()
}
fun refresh(rule: Rule) {
ruleDetailComposite.refresh(rule)
}
private fun initToolBar() {
val bars = viewSite.actionBars
val tm = bars.toolBarManager
val rulesAction = object : Action("Show Rules") {
override fun run() {
val shell = Shell(Display.getDefault())
shell.text = "All Rules"
shell.layout = FillLayout()
val sc = ScrolledComposite(shell, SWT.V_SCROLL or SWT.H_SCROLL)
val rulesView = AllRulesView(sc)
sc.expandHorizontal = true
sc.expandVertical = true
sc.content = rulesView.content
shell.open()
}
}
rulesAction.imageDescriptor = SmartfoxActivator.getImageDescriptor("icons/actions/rules.png")
tm.add(Separator("Markers"))
tm.add(rulesAction)
}
companion object {
fun showAndGetView(): RuleDetailView {
return PlatformUI.getWorkbench().activeWorkbenchWindow.activePage.showView(
"com.alibaba.smartfox.eclipse.ui.RuleDetailView", null,
IWorkbenchPage.VIEW_VISIBLE) as RuleDetailView
}
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/Violations.kt
================================================
/*
* Copyright 1999-2017 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.smartfox.eclipse.ui
import com.alibaba.smartfox.eclipse.util.MarkerUtil
import net.sourceforge.pmd.RuleViolation
import org.eclipse.core.resources.IFile
import org.eclipse.core.resources.IMarker
/**
*
*
* @author caikang
* @date 2017/06/13
*/
data class LevelViolations(var level: String, var rules: List<RuleViolations>,
var count: Int = rules.sumBy { it.count }) {
fun removeMarkers() {
rules.forEach {
it.removeMarkers()
}
}
override fun equals(other: Any?): Boolean {
if (other !is LevelViolations) {
return false
}
return level == other.level
}
override fun hashCode(): Int {
return level.hashCode()
}
}
data class RuleViolations(var rule: String, var files: List<FileMarkers>,
var count: Int = files.sumBy { it.markers.size }) {
fun removeMarkers() {
files.forEach {
it.removeMarkers()
}
}
override fun equals(other: Any?): Boolean {
if (other !is RuleViolations) {
return false
}
return rule == other.rule
}
override fun hashCode(): Int {
return rule.hashCode()
}
}
data class FileMarkers(var file: IFile, var markers: List<MarkerViolation>) {
fun removeMarkers() {
MarkerUtil.removeAllMarkers(file)
}
override fun equals(other: Any?): Boolean {
if (other !is FileMarkers) {
return false
}
return file == other.file
}
override fun hashCode(): Int {
return file.hashCode()
}
}
data class MarkerViolation(val marker: IMarker, val violation: RuleViolation)
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/pmd/BasicLineStyleListener.kt
================================================
package com.alibaba.smartfox.eclipse.ui.pmd
import org.eclipse.swt.custom.LineStyleEvent
import org.eclipse.swt.custom.LineStyleListener
/**
* This class performs the syntax highlighting and styling for Pmpe
* * PmpeLineStyleListener constructor
* @param theSyntaxData the syntax data to use
*/
class BasicLineStyleListener(theSyntaxData: SyntaxData) : StyleExtractor(theSyntaxData), LineStyleListener {
/**
* Called by StyledText to get styles for a line
*/
override fun lineGetStyle(event: LineStyleEvent) {
val styles = lineStylesFor(event.lineText, event.lineOffset, event.lineText.length)
event.styles = styles.toTypedArray()
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/pmd/ContentBuilder.kt
================================================
package com.alibaba.smartfox.eclipse.ui.pmd
import net.sourceforge.pmd.lang.Language
import org.eclipse.swt.SWT
import org.eclipse.swt.custom.StyleRange
import org.eclipse.swt.custom.StyledText
import org.eclipse.swt.graphics.Point
import org.eclipse.swt.widgets.Display
import org.eclipse.ui.PlatformUI
import java.net.URL
import java.util.ArrayList
import java.util.Arrays
import java.util.HashMap
/**
*
* @author caikang
* @date 2017/07/20
*/
class ContentBuilder {
private val CR = '\n'
private val buffer = StringBuilder()
private val headingSpans = ArrayList<IntArray>()
private val codeSpans = ArrayList<IntArray>()
private val linksBySpan = HashMap<IntArray, String>()
private val indentDepth: Int = 3
private val codeStyleExtractor = StyleExtractor(SyntaxManager.getSyntaxData("java"))
private val background = Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)
private val headingColor = Display.getCurrent().getSystemColor(SWT.COLOR_BLUE)
private val codeStyle = FontBuilder("Courier", 11, SWT.NORMAL).style(Display.getCurrent())
fun clear() {
buffer.setLength(0)
headingSpans.clear()
codeSpans.clear()
linksBySpan.clear()
}
fun addHeading(heading: String) {
var length = buffer.length
if (length > 0) {
buffer.append(CR)
length += 1
}
headingSpans.add(intArrayOf(length, length + heading.length))
buffer.append(heading).append(CR)
}
fun addText(text: String) {
for (i in 0 until indentDepth) {
buffer.append(' ')
}
buffer.append(text).append(CR)
}
fun addRawText(text: String) {
buffer.append(text)
}
fun addCode(code: String) {
val length = buffer.length
codeSpans.add(intArrayOf(length, length + code.length))
buffer.append(code)
}
fun setLanguage(language: Language) {
val syntax = SyntaxManager.getSyntaxData(language.terseName)
codeStyleExtractor.syntax(syntax)
}
fun hasLinks(): Boolean {
return linksBySpan.isNotEmpty()
}
fun addLinkHandler(widget: StyledText) {
widget.addListener(SWT.MouseDown) { event ->
// It is up to the application to determine when and how a link
// should be activated.
// In this snippet links are activated on mouse down when the
// control key is held down
// if ((event.stateMask & SWT.MOD1) != 0) {
try {
val offset = widget.getOffsetAtLocation(Point(event.x, event.y))
val link = linkAt(offset)
if (link != null) {
launchBrowser(link)
}
} catch (e: IllegalArgumentException) {
// no character under event.x, event.y
}
}
}
private fun linkAt(textIndex: Int): String? {
var span: IntArray
for ((key, value) in linksBySpan) {
span = key
if (span[0] <= textIndex && textIndex <= span[1]) {
return value
}
}
return null
}
private fun launchBrowser(link: String) {
try {
val browser = PlatformUI.getWorkbench().browserSupport.externalBrowser
browser.openURL(URL(link))
} catch (ex: Exception) {
ex.printStackTrace()
}
}
fun showOn(widget: StyledText) {
val text = buffer.toString()
widget.text = text
val ranges = ArrayList<StyleRange>()
var span: IntArray
for (i in headingSpans.indices) {
span = headingSpans[i]
ranges.add(StyleRange(span[0], span[1] - span[0], headingColor, background, SWT.BOLD))
}
for (spn in linksBySpan.keys) {
val style = StyleRange(spn[0], spn[1] - spn[0], headingColor, background, SWT.UNDERLINE_LINK)
style.underline = true
ranges.add(style)
}
val crStr = Character.toString(CR)
var sr: StyleRange
for (i in codeSpans.indices) {
span = codeSpans[i]
sr = StyleRange(codeStyle)
sr.start = span[0]
sr.length = span[1] - span[0]
val colorRanges = codeStyleExtractor.stylesFor(text, sr.start, sr.length, crStr)
ranges += colorRanges
}
// must be in order!
val styles = sort(ranges)
widget.styleRanges = styles
}
private fun sort(ranges: List<StyleRange>): Array<StyleRange> {
val styles = ranges.toTypedArray()
Arrays.sort(styles) { sr1, sr2 -> sr1.start - sr2.start }
return styles
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/pmd/FontBuilder.kt
================================================
package com.alibaba.smartfox.eclipse.ui.pmd
import org.eclipse.swt.graphics.Font
import org.eclipse.swt.graphics.TextStyle
import org.eclipse.swt.widgets.Display
/**
* @author Brian Remedios
*/
class FontBuilder(val name: String, val size: Int, val style: Int, val colorIdx: Int = -1) {
fun build(display: Display): Font {
return Font(display, name, size, style)
}
fun style(display: Display): TextStyle {
return TextStyle(build(display), if (colorIdx < 0) null else display.getSystemColor(colorIdx), null)
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/pmd/StringArranger.kt
================================================
package com.alibaba.smartfox.eclipse.ui.pmd
import net.sourceforge.pmd.util.StringUtil
import java.util.ArrayList
/**
* @author Brian Remedios
*/
class StringArranger(private val indentString: String) {
fun withIndent(rawText: String): String {
return indentString + rawText
}
fun format(rawText: String): StringBuilder {
val sb = StringBuilder()
for (line in trimmedLinesIn(rawText)) {
sb.append(indentString)
sb.append(line).append(CR)
}
return sb
}
fun trimmedLinesIn(text: String): List<String> {
val lines = text.split("\n".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
if (lines.isEmpty()) {
return emptyList()
}
val lineSet = ArrayList<String>(lines.size)
var startLine = 0
while (startLine < lines.size && StringUtil.isEmpty(lines[startLine])) {
startLine++
}
var endLine = lines.size - 1
while (endLine >= 0 && StringUtil.isEmpty(lines[endLine])) {
endLine--
}
lines.mapTo(lineSet) {
it.trim { it <= ' ' }
}
return lineSet
}
companion object {
private val CR = '\n'
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/pmd/StyleExtractor.kt
================================================
package com.alibaba.smartfox.eclipse.ui.pmd
import net.sourceforge.pmd.util.StringUtil
import org.eclipse.swt.SWT
import org.eclipse.swt.custom.StyleRange
import org.eclipse.swt.widgets.Display
import java.util.ArrayList
import java.util.LinkedList
/**
* @author Brian Remedios
*/
open class StyleExtractor(private var syntaxData: SyntaxData?) {
private val commentOffsets: MutableList<IntArray>
init {
commentOffsets = LinkedList<IntArray>()
}
fun syntax(theSyntax: SyntaxData?) {
syntaxData = theSyntax
}
/**
* Refreshes the offsets for all multiline comments in the parent
* StyledText. The parent StyledText should call this whenever its text is
* modified. Note that this code doesn't ignore comment markers inside
* strings.
* @param text the text from the StyledText
*/
fun refreshMultilineComments(text: String) {
// Clear any stored offsets
commentOffsets.clear()
if (syntaxData != null) {
// Go through all the instances of COMMENT_START
var pos = text.indexOf(syntaxData!!.multiLineCommentStart!!)
while (pos > -1) {
// offsets[0] holds the COMMENT_START offset
// and COMMENT_END holds the ending offset
val offsets = IntArray(2)
offsets[0] = pos
// Find the corresponding end comment.
pos = text.indexOf(syntaxData!!.multiLineCommentEnd!!, pos)
// If no corresponding end comment, use the end of the text
offsets[1] = if (pos == -1) text.length - 1 else pos + syntaxData!!.multiLineCommentEnd!!.length - 1
pos = offsets[1]
// Add the offsets to the collection
commentOffsets.add(offsets)
pos = text.indexOf(syntaxData!!.multiLineCommentStart!!, pos)
}
}
}
/**
* Checks to see if the specified section of text begins inside a multiline
* comment. Returns the index of the closing comment, or the end of the line
* if the whole line is inside the comment. Returns -1 if the line doesn't
* begin inside a comment.
* @param start the starting offset of the text
* @param length the length of the text
* @return int
*/
private fun getBeginsInsideComment(start: Int, length: Int): Int {
// Assume section doesn't being inside a comment
var index = -1
// Go through the multiline comment ranges
var i = 0
val n = commentOffsets.size
while (i < n) {
val offsets = commentOffsets[i]
// If starting offset is past range, quit
if (offsets[0] > start + length) {
break
}
// Check to see if section begins inside a comment
if (offsets[0] <= start && offsets[1] >= start) {
// It does; determine if the closing comment marker is inside
// this section
index = if (offsets[1] > start + length) start + length
else offsets[1] + syntaxData!!.multiLineCommentEnd!!.length - 1
}
i++
}
return index
}
private fun isDefinedVariable(text: String): Boolean {
return StringUtil.isNotEmpty(text)
}
private fun atMultiLineCommentStart(text: String, position: Int): Boolean {
return text.indexOf(syntaxData!!.multiLineCommentStart!!, position) == position
}
private fun atStringStart(text: String, position: Int): Boolean {
return text.indexOf(syntaxData!!.stringStart!!, position) == position
}
private fun atVarnameReference(text: String, position: Int): Boolean {
return syntaxData!!.varnameReference != null && text.indexOf(syntaxData!!.varnameReference!!,
position) == position
}
private fun atSingleLineComment(text: String, position: Int): Boolean {
return syntaxData!!.comment != null && text.indexOf(syntaxData!!.comment!!, position) == position
}
private fun getKeywordEnd(lineText: String, start: Int): Int {
val length = lineText.length
val buf = StringBuilder(length)
var i = start
// Call any consecutive letters a word
while (i < length && Character.isLetter(lineText[i])) {
buf.append(lineText[i])
i++
}
return if (syntaxData!!.isKeyword(buf.toString())) i else 0 - i
}
/**
* Chop up the text into individual lines starting from offset and then
* determine the required styles for each. Ensures the offset is properly
* accounted for in each.
* @param text
* @param offset
* @param length
* @return
*/
fun stylesFor(text: String, offset: Int, length: Int, lineSeparator: String): List<StyleRange> {
if (syntaxData == null) {
return emptyList()
}
val content = text.substring(offset, offset + length)
val lines = content.split(lineSeparator.toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
val styles = ArrayList<StyleRange>()
val separatorLength = lineSeparator.length
var currentOffset = offset
for (line in lines) {
val lineLength = line.length
val lineStyles = lineStylesFor(line, 0, lineLength)
for (sr in lineStyles) {
sr.start += currentOffset
}
styles.addAll(lineStyles)
currentOffset += lineLength + separatorLength
}
return styles
}
fun lineStylesFor(lineText: String, lineOffset: Int, length: Int): List<StyleRange> {
val styles = ArrayList<StyleRange>()
var start = 0
// Check if line begins inside a multiline comment
val mlIndex = getBeginsInsideComment(lineOffset, lineText.length)
if (mlIndex > -1) {
// Line begins inside multiline comment; create the range
styles.add(StyleRange(lineOffset, mlIndex - lineOffset, COMMENT_COLOR, COMMENT_BACKGROUND))
start = mlIndex
}
// Do punctuation, single-line comments, and keywords
while (start < length) {
// Check for multiline comments that begin inside this line
if (atMultiLineCommentStart(lineText, start)) {
// Determine where comment ends
var endComment = lineText.indexOf(syntaxData!!.multiLineCommentEnd!!, start)
// If comment doesn't end on this line, extend range to end of
// line
if (endComment == -1) {
endComment = length
} else {
endComment += syntaxData!!.multiLineCommentEnd!!.length
}
styles.add(StyleRange(lineOffset + start, endComment - start, COMMENT_COLOR, COMMENT_BACKGROUND))
start = endComment
} else if (atStringStart(lineText, start)) {
// Determine where comment ends
var endString = lineText.indexOf(syntaxData!!.stringEnd!!, start + 1)
// If string doesn't end on this line, extend range to end of
// line
if (endString == -1) {
endString = length
} else {
endString += syntaxData!!.stringEnd!!.length
}
styles.add(StyleRange(lineOffset + start, endString - start, STRING_COLOR, COMMENT_BACKGROUND))
start = endString
} else if (atSingleLineComment(lineText, start)) {
// line comments
styles.add(StyleRange(lineOffset + start, length - start, COMMENT_COLOR, COMMENT_BACKGROUND))
start = length
} else if (atVarnameReference(lineText, start)) {
// variable
// references
val buf = StringBuilder()
var i = start + syntaxData!!.varnameReference!!.length
// Call any consecutive letters a word
while (i < length && Character.isLetter(lineText[i])) {
buf.append(lineText[i])
i++
}
// See if the word is a variable
if (isDefinedVariable(buf.toString())) {
// It's a keyword; create the StyleRange
styles.add(StyleRange(lineOffset + start, i - start, REFERENCED_VAR_COLOR, null, SWT.BOLD))
}
// Move the marker to the last char (the one that wasn't a
// letter)
// so it can be retested in the next iteration through the loop
start = i
} else if (syntaxData!!.isPunctuation(lineText[start])) {
// Add range for punctuation
styles.add(StyleRange(lineOffset + start, 1, PUNCTUATION_COLOR, null))
++start
} else if (Character.isLetter(lineText[start])) {
val kwEnd = getKeywordEnd(lineText, start)
// is a keyword
if (kwEnd > start) {
styles.add(StyleRange(lineOffset + start, kwEnd - start, KEYWORD_COLOR, null))
}
// Move the marker to the last char (the one that wasn't a
// letter)
// so it can be retested in the next iteration through the loop
start = Math.abs(kwEnd)
} else {
++start // It's nothing we're interested in; advance the marker
}// Check for punctuation
}
return styles
}
companion object {
private val COMMENT_COLOR = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GREEN)
private val REFERENCED_VAR_COLOR = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GREEN)
private val UNREFERENCED_VAR_COLOR = Display.getCurrent().getSystemColor(SWT.COLOR_YELLOW)
private val COMMENT_BACKGROUND = Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)
private val PUNCTUATION_COLOR = Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)
private val KEYWORD_COLOR = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_MAGENTA)
private val STRING_COLOR = Display.getCurrent().getSystemColor(SWT.COLOR_BLUE)
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/pmd/SyntaxData.kt
================================================
package com.alibaba.smartfox.eclipse.ui.pmd
/**
* This class contains information for syntax coloring and styling for an
* extension
*/
class SyntaxData(val extension: String) {
var varnameReference: String? = null
var stringStart: String? = null
var stringEnd: String? = null
private var keywords: Collection<String>? = null
private var punctuation: String? = null
var comment: String? = null
var multiLineCommentStart: String? = null
var multiLineCommentEnd: String? = null
fun matches(otherExtension: String): Boolean {
return extension == otherExtension
}
fun isKeyword(word: String): Boolean {
return keywords != null && keywords!!.contains(word)
}
fun isPunctuation(ch: Char): Boolean {
return punctuation != null && punctuation!!.indexOf(ch) >= 0
}
fun setKeywords(keywords: Collection<String>) {
this.keywords = keywords
}
fun setPunctuation(thePunctuationChars: String) {
punctuation = thePunctuationChars
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/pmd/SyntaxManager.kt
================================================
package com.alibaba.smartfox.eclipse.ui.pmd
import org.eclipse.swt.custom.StyledText
import org.eclipse.swt.events.ModifyListener
import java.util.HashSet
import java.util.Hashtable
import java.util.MissingResourceException
import java.util.ResourceBundle
import java.util.StringTokenizer
/**
* This class manages the syntax coloring and styling data
*/
object SyntaxManager {
private val syntaxByExtension = Hashtable<String, SyntaxData>()
fun adapt(codeField: StyledText, languageCode: String, oldListener: ModifyListener?): ModifyListener? {
if (oldListener != null) {
codeField.removeModifyListener(oldListener)
}
val sd = SyntaxManager.getSyntaxData(languageCode) ?: return null
val blsl = BasicLineStyleListener(sd)
codeField.addLineStyleListener(blsl)
val ml = ModifyListener {
blsl.refreshMultilineComments(codeField.text)
codeField.redraw()
}
codeField.addModifyListener(ml)
return ml
}
/**
* Gets the syntax data for an extension
*/
@Synchronized fun getSyntaxData(extension: String): SyntaxData? {
// Check in cache
var sd: SyntaxData? = syntaxByExtension[extension]
if (sd == null) {
// Not in cache; load it and put in cache
sd = loadSyntaxData(extension)
if (sd != null) {
syntaxByExtension.put(sd.extension, sd)
}
}
return sd
}
/**
* Loads the syntax data for an extension
* @return SyntaxData
*/
private fun loadSyntaxData(filename: String): SyntaxData? {
var sd: SyntaxData? = null
try {
val rb = ResourceBundle.getBundle("/syntax/$filename")
sd = SyntaxData(filename)
sd.stringStart = rb.getString("stringstart")
sd.stringEnd = rb.getString("stringend")
sd.multiLineCommentStart = rb.getString("multilinecommentstart")
sd.multiLineCommentEnd = rb.getString("multilinecommentend")
// Load the keywords
val keywords = HashSet<String>()
val st = StringTokenizer(rb.getString("keywords"), " ")
while (st.hasMoreTokens()) {
keywords.add(st.nextToken())
}
sd.setKeywords(keywords)
// Load the punctuation
sd.setPunctuation(rb.getString("punctuation"))
if (rb.containsKey("comment")) {
sd.comment = rb.getString("comment")
}
if (rb.containsKey("varnamedelimiter")) {
sd.varnameReference = rb.getString("varnamedelimiter")
}
} catch (e: MissingResourceException) {
// Ignore
}
return sd
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/util/CleanUps.kt
================================================
// =====================================================================
//
// Copyright (C) 2012 - 2016, Philip Graf
//
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// which accompanies this distribution, and is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// =====================================================================
package com.alibaba.smartfox.eclipse.util
import com.alibaba.smartfox.eclipse.SmartfoxActivator
import org.eclipse.core.filebuffers.FileBuffers
import org.eclipse.core.filebuffers.ITextFileBuffer
import org.eclipse.core.filebuffers.LocationKind
import org.eclipse.core.resources.IFile
import org.eclipse.core.runtime.Assert
import org.eclipse.core.runtime.CoreException
import org.eclipse.core.runtime.IProgressMonitor
import org.eclipse.core.runtime.IStatus
import org.eclipse.core.runtime.NullProgressMonitor
import org.eclipse.core.runtime.Status
import org.eclipse.jdt.core.ICompilationUnit
import org.eclipse.jdt.core.IJavaProject
import org.eclipse.jdt.core.JavaCore
import org.eclipse.jdt.core.dom.CompilationUnit
import org.eclipse.jdt.internal.corext.fix.CleanUpConstants
import org.eclipse.jdt.internal.corext.fix.CleanUpRefactoring
import org.eclipse.jdt.internal.corext.fix.FixMessages
import org.eclipse.jdt.internal.corext.refactoring.util.RefactoringASTParser
import org.eclipse.jdt.internal.ui.JavaPlugin
import org.eclipse.jdt.internal.ui.actions.ActionUtil
import org.eclipse.jdt.internal.ui.fix.MapCleanUpOptions
import org.eclipse.jdt.ui.SharedASTProvider
import org.eclipse.jdt.ui.cleanup.CleanUpContext
import org.eclipse.jdt.ui.cleanup.CleanUpOptions
import org.eclipse.jdt.ui.cleanup.ICleanUp
import org.eclipse.jface.text.BadLocationException
import org.eclipse.jface.text.IDocument
import org.eclipse.jface.text.IDocumentExtension4
import org.eclipse.jface.window.Window
import org.eclipse.ltk.core.refactoring.Change
import org.eclipse.ltk.core.refactoring.CompositeChange
import org.eclipse.ltk.core.refactoring.IRefactoringCoreStatusCodes
import org.eclipse.ltk.core.refactoring.NullChange
import org.eclipse.ltk.core.refactoring.PerformChangeOperation
import org.eclipse.ltk.core.refactoring.RefactoringCore
import org.eclipse.ltk.core.refactoring.RefactoringStatus
import org.eclipse.ltk.core.refactoring.TextFileChange
import org.eclipse.ltk.ui.refactoring.RefactoringUI
import org.eclipse.text.edits.MalformedTreeException
import org.eclipse.text.edits.TextEdit
import org.eclipse.text.edits.UndoEdit
import org.eclipse.ui.PlatformUI
import java.util.ArrayList
import java.util.HashMap
import java.util.LinkedList
/**
*
*
* @author caikang
* @date 2017/06/15
*/
object CleanUps {
private val WARNING_VALUE = "warning"
private val ERROR_VALUE = "error"
val cleanUpSettings = mapOf(CleanUpConstants.ADD_MISSING_ANNOTATIONS to CleanUpOptions.TRUE,
CleanUpConstants.CONTROL_STATMENTS_USE_BLOCKS_ALWAYS to CleanUpOptions.TRUE,
CleanUpConstants.ADD_MISSING_ANNOTATIONS_OVERRIDE to CleanUpOptions.TRUE,
CleanUpConstants.CONTROL_STATEMENTS_USE_BLOCKS to CleanUpOptions.TRUE,
CleanUpConstants.ADD_MISSING_ANNOTATIONS_OVERRIDE_FOR_INTERFACE_METHOD_IMPLEMENTATION to
CleanUpOptions.TRUE)
fun fix(file: IFile, monitor: IProgressMonitor) {
val compilationUnit = JavaCore.createCompilationUnitFrom(file) ?: return
doCleanUp(compilationUnit, monitor)
}
@Throws(CoreException::class) fun doCleanUp(unit: ICompilationUnit, monitor: IProgressMonitor) {
monitor.beginTask("Fix", IProgressMonitor.UNKNOWN)
if (!ActionUtil.isOnBuildPath(unit)) return
val result = CompositeChange(FixMessages.CleanUpPostSaveListener_SaveAction_ChangeName)
val undoEdits = LinkedList<UndoEdit>()
val oldFileValue = unit.resource.modificationStamp
val oldDocValue = getDocumentStamp(unit.resource as IFile, monitor)
val manager = RefactoringCore.getUndoManager()
var success = false
try {
manager.aboutToPerformChange(result)
success = doCleanUp(unit, monitor, result, undoEdits)
} finally {
manager.changePerformed(result, success)
}
if (undoEdits.size > 0) {
val undoEditArray = undoEdits.toTypedArray()
val undo = CleanUpSaveUndo(result.name, unit.resource as IFile, undoEditArray, oldDocValue, oldFileValue)
undo.initializeValidationData(NullProgressMonitor())
manager.addUndo(result.name, undo)
}
}
@Throws(CoreException::class) private fun getDocumentStamp(file: IFile, monitor: IProgressMonitor): Long {
val manager = FileBuffers.getTextFileBufferManager()
val path = file.fullPath
monitor.beginTask("", 2)
var buffer: ITextFileBuffer? = null
try {
manager.connect(path, LocationKind.IFILE, monitor)
buffer = manager.getTextFileBuffer(path, LocationKind.IFILE)
val document = buffer!!.document
if (document is IDocumentExtension4) {
return document.modificationStamp
} else {
return file.modificationStamp
}
} finally {
if (buffer != null) manager.disconnect(path, LocationKind.IFILE, monitor)
monitor.done()
}
}
private fun doCleanUp(unit: ICompilationUnit, monitor: IProgressMonitor, result: CompositeChange,
undoEdits: LinkedList<UndoEdit>): Boolean {
val cleanUps = JavaPlugin.getDefault().cleanUpRegistry.createCleanUps(
setOf("org.eclipse.jdt.ui.cleanup.java50", "org.eclipse.jdt.ui.cleanup.control_statements"))
val preCondition = RefactoringStatus()
val postCondition = RefactoringStatus()
cleanUps.forEach { cleanUp ->
cleanUp.setOptions(MapCleanUpOptions(cleanUpSettings))
preCondition.merge(cleanUp.checkPreConditions(unit.javaProject, arrayOf(unit), monitor))
val options = HashMap<String, String>(cleanUp.requirements.compilerOptions ?: emptyMap())
var ast = CleanUps.createAst(unit, options, monitor)
if (cleanUp.requirements.requiresAST()) {
ast = createAst(unit, options, monitor)
}
val context = CleanUpContext(unit, ast)
val undoneCleanUps = ArrayList<ICleanUp>()
val change = CleanUpRefactoring.calculateChange(context, arrayOf(cleanUp), undoneCleanUps, null)
postCondition.merge(cleanUp.checkPostConditions(monitor))
if (showStatus(postCondition) != Window.OK) {
return@doCleanUp false
}
if (change == null) {
return@forEach
}
result.add(change)
change.initializeValidationData(NullProgressMonitor())
val performChangeOperation = PerformChangeOperation(change)
performChangeOperation.setSchedulingRule(unit.schedulingRule)
performChangeOperation.run(monitor)
performChangeOperation.undoChange
undoEdits.addFirst(change.undoEdit)
}
return true
}
private fun showStatus(status: RefactoringStatus): Int {
if (!status.hasError()) return Window.OK
val shell = PlatformUI.getWorkbench().activeWorkbenchWindow.shell
val dialog = RefactoringUI.createRefactoringStatusDialog(status, shell, "", false)
return dialog.open()
}
private fun createAst(unit: ICompilationUnit, cleanUpOptions: Map<String, String>,
monitor: IProgressMonitor): CompilationUnit {
val project = unit.javaProject
if (compatibleOptions(project, cleanUpOptions)) {
val ast = SharedASTProvider.getAST(unit, SharedASTProvider.WAIT_NO, monitor)
if (ast != null) return ast
}
val parser = CleanUpRefactoring.createCleanUpASTParser()
parser.setSource(unit)
val compilerOptions = RefactoringASTParser.getCompilerOptions(unit.javaProject)
compilerOptions.putAll(cleanUpOptions)
parser.setCompilerOptions(compilerOptions)
return parser.createAST(monitor) as CompilationUnit
}
private fun compatibleOptions(project: IJavaProject, cleanUpOptions: Map<String, String>): Boolean {
if (cleanUpOptions.isEmpty()) {
return true
}
val projectOptions = project.getOptions(true)
return !cleanUpOptions.keys.any {
val projectOption = projectOptions[it]?.toString()
val cleanUpOption = cleanUpOptions[it]?.toString()
!strongerEquals(projectOption, cleanUpOption)
}
}
private fun strongerEquals(projectOption: String?, cleanUpOption: String?): Boolean {
if (projectOption == null) return false
if (ERROR_VALUE == cleanUpOption) {
return ERROR_VALUE == projectOption
} else if (WARNING_VALUE == cleanUpOption) {
return ERROR_VALUE == projectOption || WARNING_VALUE == projectOption
}
return false
}
private class CleanUpSaveUndo(name: String, private val fFile: IFile, private val fUndos: Array<UndoEdit>,
private val fDocumentStamp: Long, private val fFileStamp: Long) : TextFileChange(name,
fFile) {
init {
Assert.isNotNull(fUndos)
}
public override fun needsSaving(): Boolean {
return true
}
@Throws(CoreException::class) override fun perform(monitor: IProgressMonitor?): Change {
val pm = monitor ?: NullProgressMonitor()
if (isValid(pm).hasFatalError()) return NullChange()
val manager = FileBuffers.getTextFileBufferManager()
pm.beginTask("", 2)
var buffer: ITextFileBuffer? = null
try {
manager.connect(fFile.fullPath, LocationKind.IFILE, pm)
buffer = manager.getTextFileBuffer(fFile.fullPath, LocationKind.IFILE)
val document = buffer!!.document
val oldFileValue = fFile.modificationStamp
val undoEditCollector = LinkedList<UndoEdit>()
val oldDocValue = LongArray(1)
val setContentStampSuccess = booleanArrayOf(false)
if (!buffer.isSynchronizationContextRequested) {
performEdit(document, oldFileValue, undoEditCollector, oldDocValue, setContentStampSuccess)
} else {
val fileBufferManager = FileBuffers.getTextFileBufferManager()
class UIRunnable : Runnable {
var fDone: Boolean = false
var fException: Exception? = null
override fun run() {
synchronized(this) {
try {
performEdit(document, oldFileValue, undoEditCollector, oldDocValue,
setContentStampSuccess)
} catch (e: BadLocationException) {
fException = e
} catch (e: MalformedTreeException) {
fException = e
} catch (e: CoreException) {
fException = e
} finally {
fDone = true
(this as Object).notifyAll()
}
}
}
}
val runnable = UIRunnable()
synchronized(runnable) {
fileBufferManager.execute(runnable)
while (!runnable.fDone) {
try {
(runnable as Object).wait(500)
} catch (x: InterruptedException) {
}
}
}
if (runnable.fException != null) {
if (runnable.fException is BadLocationException) {
throw runnable.fException as BadLocationException
} else if (runnable.fException is MalformedTreeException) {
throw runnable.fException as MalformedTreeException
} else if (runnable.fException is CoreException) {
throw runnable.fException as CoreException
}
}
}
buffer.commit(pm, false)
if (!setContentStampSuccess[0]) {
fFile.revertModificationStamp(fFileStamp)
}
return CleanUpSaveUndo(name, fFile, undoEditCollector.toTypedArray(), oldDocValue[0], oldFileValue)
} catch (e: BadLocationException) {
throw wrapBadLocationException(e)
} finally {
if (buffer != null) manager.disconnect(fFile.fullPath, LocationKind.IFILE, pm)
}
}
@Throws(MalformedTreeException::class, BadLocationException::class,
CoreException::class) private fun performEdit(document: IDocument, oldFileValue: Long,
editCollector: LinkedList<UndoEdit>,
oldDocValue: LongArray,
setContentStampSuccess: BooleanArray) {
if (document is IDocumentExtension4) {
oldDocValue[0] = document.modificationStamp
} else {
oldDocValue[0] = oldFileValue
}
// perform the changes
fUndos.map { it.apply(document, TextEdit.CREATE_UNDO) }.forEach { editCollector.addFirst(it) }
if (document is IDocumentExtension4 && fDocumentStamp != IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP) {
try {
document.replace(0, 0, "", fDocumentStamp)
setContentStampSuccess[0] = true
} catch (e: BadLocationException) {
throw wrapBadLocationException(e)
}
}
}
}
private fun wrapBadLocationException(e: BadLocationException): CoreException {
var message: String? = e.message
if (message == null) message = "BadLocationException"
return CoreException(
Status(IStatus.ERROR, SmartfoxActivator.PLUGIN_ID, IRefactoringCoreStatusCodes.BAD_LOCATION, message,
e))
}
}
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/util/MarkerUtil.kt
================================================
// =====================================================================
//
// Copyright (C) 2012 - 2016, Philip Graf
//
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// which accompanies this distribution, and is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// =====================================================================
package com.alibaba.smartfox.eclipse.util
import com.alibaba.smartfox.eclipse.QuickFixGenerator
import com.alibaba.smartfox.eclipse.SmartfoxActivator
import com.google.common.io.Files
import net.sourceforge.pmd.Rule
import net.sourceforge.pmd.RulePriority
import net.sourceforge.pmd.RuleViolation
import org.eclipse.core.resources.IFile
import org.eclipse.core.resources.IMarker
import org.eclipse.core.resources.IProject
import org.eclipse.core.resources.IResource
import org.eclipse.core.runtime.CoreException
import org.eclipse.jface.text.BadLocationException
import org.eclipse.jface.text.Document
import org.eclipse.ui.IMarkerResolution
import java.nio.charset.Charset
/**
* @author caikang
* @date 2017/06/08
*/
object MarkerUtil {
private val PMD_TAB_SIZE = 8
private val MARKER_TYPE = "${SmartfoxActivator.PLUGIN_ID}.p3cMarker"
@Throws(CoreException::class)
fun removeAllMarkers(file: IFile) {
try {
if (file.exists()) {
file.deleteMarkers(MARKER_TYPE, true, IResource.DEPTH_ZERO)
}
} catch (e: Exception) {
SmartfoxActivator.instance.logError(e.message ?: "", e)
}
}
@Throws(CoreException::class)
fun removeAllMarkers(project: IProject) {
project.deleteMarkers(MARKER_TYPE, true, IResource.DEPTH_INFINITE)
}
@Throws(CoreException::class)
fun addMarker(file: IFile, violation: RuleViolation): IMarker {
val marker = file.createMarker(MARKER_TYPE)
marker.setAttribute(IMarker.MESSAGE, violation.description)
val severity = when (violation.rule.priority) {
RulePriority.HIGH -> IMarker.SEVERITY_ERROR
RulePriority.MEDIUM_HIGH -> IMarker.SEVERITY_WARNING
else -> IMarker.SEVERITY_INFO
}
marker.setRule(violation.rule.name)
marker.setAttribute(IMarker.SEVERITY, severity)
marker.setAttribute(IMarker.LINE_NUMBER, Math.max(violation.beginLine, 0))
val range = getAbsoluteRange(file, violation)
val start = Math.max(range.start, 0)
marker.setAttribute(IMarker.CHAR_START, start)
val end = Math.max(range.end, 0)
marker.setAttribute(IMarker.CHAR_END, end)
return marker
}
fun getAbsoluteRange(file: IFile, violation: RuleViolation): Range {
val content = Files.toString(file.rawLocation.toFile(), Charset.forName(file.charset))
try {
return calculateAbsoluteRange(content, violation)
} catch (e: BadLocationException) {
return Range(0, 0)
}
}
@Throws(BadLocationException::class) private fun calculateAbsoluteRange(content: String,
violation: RuleViolation): Range {
val document = Document(content)
// violation line and column start at one, the marker's start and end positions at zero
val start = getAbsolutePosition(content, document.getLineOffset(violation.beginLine - 1), violation.beginColumn)
val end = getAbsolutePosition(content, document.getLineOffset(violation.endLine - 1), violation.endColumn)
// for some rules PMD creates violations with the end position before the start position
val range = if (start <= end) {
Range(start - 1, end)
} else {
Range(end - 1, start)
}
return range
}
private fun getAbsolutePosition(content: String, lineOffset: Int, pmdCharOffset: Int): Int {
var pmdCharCounter = 0
var absoluteOffset = lineOffset
while (pmdCharCounter < pmdCharOffset) {
if (absoluteOffset < content.length) {
val c = content[absoluteOffset]
if (c == '\t') {
pmdCharCounter = (pmdCharCounter / PMD_TAB_SIZE + 1) * PMD_TAB_SIZE
} else {
pmdCharCounter++
}
} else {
break
}
absoluteOffset++
}
return absoluteOffset
}
}
fun IMarker.setRule(rule: String) {
this.setAttribute("rule", rule)
}
fun IMarker.getRule(): Rule {
return SmartfoxActivator.instance.getRule(this.getAttribute("rule") as String)
}
fun IMarker.getResolution(): IMarkerResolution? {
return QuickFixGenerator.quickFixes[getRule().name]
}
data class Range(val start: Int, val end: Int)
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/resources/messages/P3cBundle.xml
================================================
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<entry key="com.alibaba.smartfox.eclipse.handler.CodeAnalysisHandler">阿里编码规约扫描</entry>
<entry key="com.alibaba.smartfox.eclipse.handler.SwitchLanguageHandler.text.cur_zh">切换语言至英文(English)</entry>
<entry key="com.alibaba.smartfox.eclipse.handler.SwitchLanguageHandler.text.cur_en">切换语言至中文</entry>
<entry key="com.alibaba.smartfox.eclipse.handler.SwitchLanguageHandler.success.en">切换到English成功,是否重启</entry>
<entry key="com.alibaba.smartfox.eclipse.handler.SwitchLanguageHandler.success.zh">切换到中文成功,是否重启</entry>
<entry key="rule.standalone.MissingOverrideAnnotationRule.msg"><![CDATA[所有的覆写方法,必须加@Override注解。]]></entry>
<entry key="rule.standalone.MissingOverrideAnnotationRule.desc"><![CDATA[反例:getObject()与get0bject()的问题。一个是字母的O,一个是数字的0,加@Override可以准确判断是否覆盖成功。另外,如果在抽象类中对方法签名进行修改,其实现类会马上编译报错。]]></entry>
<entry key="rule.standalone.MissingOverrideAnnotationRule.error"><![CDATA[方法缺少 '@Override' 注解]]></entry>
<entry key="rule.standalone.AvoidAccessStaticViaInstanceRule.msg"><![CDATA[避免通过一个类的对象引用访问此类的静态变量或静态方法,无谓增加编译器解析成本,直接用类名来访问即可。]]></entry>
<entry key="rule.standalone.AvoidUseDeprecationRule.msg"><![CDATA[不能使用过时的类或方法。]]></entry>
<entry key="rule.standalone.AvoidUseDeprecationRule.desc"><![CDATA[说明:java.net.URLDecoder 中的方法decode(String encodeStr) 这个方法已经过时,应该使用双参数decode(String source, String encode)。接口提供方既然明确是过时接口,那么有义务同时提供新的接口;作为调用方来说,有义务去考证过时方法的新实现是什么。]]></entry>
<entry key="rule.standalone.MapOrSetKeyShouldOverrideHashCodeEqualsRule.msg"><![CDATA[Map/Set的key为自定义对象时,必须重写hashCode和equals。]]></entry>
<entry key="rule.standalone.MapOrSetKeyShouldOverrideHashCodeEqualsRule.desc"><![CDATA[关于hashCode和equals的处理,遵循如下规则:
1) 只要重写equals,就必须重写hashCode。
2) 因为Set存储的是不重复的对象,依据hashCode和equals进行判断,所以Set存储的对象必须重写这两个方法。
3) 如果自定义对象做为Map的键,那么必须重写hashCode和equals。]]></entry>
</properties>
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/resources/messages/P3cBundle_en.xml
================================================
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<entry key="com.alibaba.smartfox.eclipse.handler.CodeAnalysisHandler">Alibaba Coding Guidelines Analyze</entry>
<entry key="com.alibaba.smartfox.eclipse.handler.SwitchLanguageHandler.text.cur_zh">Switch language to English</entry>
<entry key="com.alibaba.smartfox.eclipse.handler.SwitchLanguageHandler.text.cur_en">Switch language to Chinese</entry>
<entry key="com.alibaba.smartfox.eclipse.handler.SwitchLanguageHandler.success.en">Switch language to English success,restart?</entry>
<entry key="com.alibaba.smartfox.eclipse.handler.SwitchLanguageHandler.success.zh">Switch language to Chinese success,restart?</entry>
<entry key="rule.standalone.MissingOverrideAnnotationRule.msg"><![CDATA[An overridden method from an interface or abstract class must be marked with @Override annotation.]]></entry>
<entry key="rule.standalone.MissingOverrideAnnotationRule.desc"><![CDATA[
Counter example: For getObject() and get0bject(), the first one has a letter 'O', and the second one has a number '0'. To accurately determine whether the overriding is successful, an @Override annotation is necessary. Meanwhile, once the method signature in the abstract class is changed, the implementation class will report a compile-time error immediately.]]></entry>
<entry key="rule.standalone.MissingOverrideAnnotationRule.error"><![CDATA[Method missing '@Override' annotation]]></entry>
<entry key="rule.standalone.AvoidAccessStaticViaInstanceRule.msg"><![CDATA[A static field or method should be directly referred by its class name instead of its corresponding object name.]]></entry>
<entry key="rule.standalone.AvoidUseDeprecationRule.msg"><![CDATA[Using a deprecated class or method is prohibited.]]></entry>
<entry key="rule.standalone.AvoidUseDeprecationRule.desc"><![CDATA[Note: For example, decode(String source, String encode) should be used instead of the deprecated method decode(String encodeStr). Once an interface has been deprecated, the interface provider has the obligation to provide a new one. At the same time, client programmers have the obligation to check out what its new implementation is.]]></entry>
<entry key="rule.standalone.MapOrSetKeyShouldOverrideHashCodeEqualsRule.msg"><![CDATA[Custom class must override 'hashCode' and 'equals' while use as key for Map or value for Set.]]></entry>
<entry key="rule.standalone.MapOrSetKeyShouldOverrideHashCodeEqualsRule.desc"><![CDATA[The usage of hashCode and equals should follow:
1) Override hashCode if equals is overridden.
2) These two methods must be overridden for Set since they are used to ensure that no duplicate object will be inserted in Set.
3) These two methods must be overridden if self-defined object is used as the key of Map.
Note: String can be used as the key of Map since these two methods have been rewritten.]]></entry>
</properties>
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/resources/rulesets/java/ali-pmd.xml
================================================
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="alibaba-pmd"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
<rule ref="rulesets/java/ali-concurrent.xml"/>
<rule ref="rulesets/java/ali-comment.xml"/>
<rule ref="rulesets/java/ali-naming.xml"/>
<rule ref="rulesets/java/ali-constant.xml"/>
<rule ref="rulesets/java/ali-other.xml"/>
<rule ref="rulesets/java/ali-flowcontrol.xml"/>
<rule ref="rulesets/java/ali-oop.xml"/>
<rule ref="rulesets/java/ali-orm.xml"/>
<rule ref="rulesets/java/ali-exception.xml"/>
<rule ref="rulesets/java/ali-set.xml"/>
<rule ref="rulesets/java/ali-ruleOnEclipse.xml"/>
</ruleset>
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/resources/rulesets/java/ali-ruleOnEclipse.xml
================================================
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="AlibabaRuleOnEclipse"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
<rule name="MissingOverrideAnnotationRule" message="rule.standalone.MissingOverrideAnnotationRule.msg"
class="com.alibaba.smartfox.eclipse.pmd.rule.MissingOverrideAnnotationRule">
<description>rule.standalone.MissingOverrideAnnotationRule.desc</description>
<priority>1</priority>
<example>
<![CDATA[
/**
* @author caikang
* @date 2016/12/24
*/
public class MissingOverrideAnnotationRule extends AbstractEclipseRule {
@Override
public Object visit(ASTCompilationUnit node, Object data) {
return super.visit(node, data);
}
}
]]>
</example>
</rule>
<rule name="AvoidAccessStaticViaInstanceRule" message="rule.standalone.AvoidAccessStaticViaInstanceRule.msg"
class="com.alibaba.smartfox.eclipse.pmd.rule.AvoidAccessStaticViaInstanceRule">
<priority>1</priority>
</rule>
<rule name="AvoidUseDeprecationRule" message="rule.standalone.AvoidUseDeprecationRule.msg"
class="com.alibaba.smartfox.eclipse.pmd.rule.AvoidUseDeprecationRule">
<description>rule.standalone.AvoidUseDeprecationRule.desc</description>
<priority>2</priority>
</rule>
<rule name="MapOrSetKeyShouldOverrideHashCodeEqualsRule" message="rule.standalone.MapOrSetKeyShouldOverrideHashCodeEqualsRule.msg"
class="com.alibaba.smartfox.eclipse.pmd.rule.MapOrSetKeyShouldOverrideHashCodeEqualsRule">
<description>rule.standalone.MapOrSetKeyShouldOverrideHashCodeEqualsRule.desc</description>
<priority>2</priority>
</rule>
</ruleset>
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/resources/syntax/java.properties
================================================
# This file contains the syntax data for .java files
comment=//
stringstart="
stringend="
multilinecommentstart=/*
multilinecommentend=*/
punctuation=(){};:?<>=+-*/&|~!%.[]
keywords=abstract assert boolean break byte case catch char class const continue do double else enum extends false final finally for if implements import int interface native new null package protected public private return static strictfp super switch synchronized this throws true try void volatile while
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.updatesite/category.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<site>
<description url="https://p3c.alibaba.com/plugin/eclipse/update">
Alibaba Java Coding Guidelines
</description>
<feature id="com.alibaba.smartfox.eclipse.feature" version="0.0.0">
<category name="Smartfox"/>
</feature>
<category-def name="Smartfox" label="Smartfox Eclipse Plugin"/>
</site>
================================================
FILE: eclipse-plugin/com.alibaba.smartfox.eclipse.updatesite/pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.alibaba.smartfox.eclipse</groupId>
<artifactId>smartfox-eclipse</artifactId>
<version>2.0.1-SNAPSHOT</version>
</parent>
<artifactId>com.alibaba.smartfox.eclipse.updatesite</artifactId>
<packaging>eclipse-repository</packaging>
<inceptionYear>2017</inceptionYear>
</project>
================================================
FILE: eclipse-plugin/pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.alibaba.smartfox.eclipse</groupId>
<artifactId>smartfox-eclipse</artifactId>
<version>2.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<inceptionYear>2017</inceptionYear>
<properties>
<tycho.version>1.0.0</tycho.version>
<tycho-extras.version>${tycho.version}</tycho-extras.version>
<eclipse-repo.url>http://download.eclipse.org/releases/neon</eclipse-repo.url>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<ajdt-eclipse-repo.url>http://download.eclipse.org/tools/ajdt/46/dev/update</ajdt-eclipse-repo.url>
<kotlin.version>1.3.30</kotlin.version>
<eclipse-release>juno</eclipse-release>
</properties>
<modules>
<module>com.alibaba.smartfox.eclipse.plugin</module>
<module>com.alibaba.smartfox.eclipse.feature</module>
<module>com.alibaba.smartfox.eclipse.updatesite</module>
</modules>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
</dependencyManagement>
<repositories>
<repository>
<id>juno</id>
<layout>p2</layout>
<url>http://mirrors.ustc.edu.cn/eclipse/releases/juno/</url>
</repository>
<repository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho.version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<configuration>
<environments>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86</arch>
</environment>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86</arch>
</environment>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>macosx</os>
<ws>cocoa</ws>
<arch>x86_64</arch>
</environment>
</environments>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho.version}</version>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-plugin</artifactId>
<version>${tycho.version}</version>
<configuration>
<compilerVersion>1.8</compilerVersion>
<compilerArguments>
<inlineJSR/>
<enableJavadoc/>
<encoding>UTF-8</encoding>
</compilerArguments>
<compilerArgument>-err:-forbidden</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>${aspectj.plugin.version}</version>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-packaging-plugin</artifactId>
<version>${tycho.version}</version>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho.version}</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-source-plugin</artifactId>
<version>${tycho.version}</version>
<configuration>
<strictSrcIncludes>false</strictSrcIncludes>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-director-plugin</artifactId>
<version>${tycho.version}</version>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-repository-plugin</artifactId>
<version>${tycho.version}</version>
<configuration>
<finalName>smartfox-eclipse-plugin</finalName>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho.extras</groupId>
<artifactId>tycho-source-feature-plugin</artifactId>
<version>${tycho-extras.version}</version>
</plugin>
<plugin>
<groupId>org.eclipse.tycho.extras</groupId>
<artifactId>tycho-custom-bundle-plugin</artifactId>
<version>${tycho-extras.version}</version>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-plugin</artifactId>
<version>${tycho.version}</version>
<configuration>
<baselineMode>warn</baselineMode>
<baselineReplace>none</baselineReplace>
<baselineRepositories>
<repository>
<url>http://download.eclipse.org/eclipse/updates/4.4</url>
</repository>
</baselineRepositories>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
================================================
FILE: idea-plugin/.gitignore
================================================
# Gradle
build
.gradle
testdata/
# Java gitignore #
.class
.log
# Package Files #
*.war
*.ear
#hsf files
configuration
# maven gitignore#
target/**
.svn/
# intelliJ.gitignore #
.idea
*.iml
*.ipr
*.iws
# Eclipse git ignore#
*.pydevproject
.project
.metadata
bin/**
*/bin/**
tmp/**
tmp/**/*
configuration/**
*.tmp
*.bak
*.orig
*.swp
*~.nib
.classpath
.settings/
.loadpath
.fileTable*
.cache
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
#log
*.log
*.log.*
# Windows Thumbs.db
*.db
# OSX
.DS_Store
# sass gitignore#
.sass-cache
.idea
# tcc_coverage
coverage.ec
config.client.*
temp/
*.pid
*.orig
hsf.configuration/
# code coverage report
*.ec
#hsf test
*.instance
out
**/idea-sandbox
================================================
FILE: idea-plugin/README.md
================================================
# Idea Plugin
---
## <font color="green">Prepare</font>
- Project JDK: 1.7+
- Gradle: 3.0+(Require JDK1.8+ for gradle)
## <font color="green">Build</font>
```
cd p3c-idea
../gradlew clean buildPlugin
```
## <font color="green">Run plugin</font>
```
cd p3c-idea
../gradlew runIde
# run specific IDEA
../gradlew runIde -Pidea_version=2018.3
```
## <font color="green">Use p3c-common as your plugin dependency</font>
```groovy
compile 'com.alibaba.p3c.idea:p3c-common:1.0.0'
```
## [中文使用手册](README_cn.md)
## <font color="green">Install</font>
### Install from repositories
1. <font color="blue">Settings >> Plugins >> Browse repositories... </font>

2. <font color="blue"> Search plugin by keyword 'alibaba' then install 'Alibaba Java Coding Guidelines' plugin </font>

3. <font color="blue">Restart to take effect. </font>
### Install from local zip file.
1. Open https://plugins.jetbrains.com/plugin/10046-alibaba-java-coding-guidelines and download the latest version zip file.

2. Settings >> Plugins >> Install plugin from disk...,select the downloaded zip file in previous step then restart your idea

## <font color="green">Use</font>
1. <font color="blue">Switch language</font>

2. <font color="blue">Inspections</font>


3. <font color="blue">Code Analyze</font>

<font color="blue">We use the idea standard Inspection Results to show our violations.</font>

<font color="blue">We can also analyze file which is modified before vcs checkin.</font>

## <font color="green">Other</font>
1. <font color="blue">[中文乱码解决方法](https://github.com/alibaba/p3c/issues/32#issuecomment-336762512)</font>
* <font color="blue">Appearance&Behavior -> Appearance -> UI Options -> Name 里面设置成微软雅黑(microsoft yahei light)</font>

* <font color="blue">Switch Language to English and restart.</font>

================================================
FILE: idea-plugin/README_cn.md
================================================
> 首先非常感谢大家对插件的支持与意见,英文版的文档还是略为简单,这里详细介绍一下插件的安装使用。
## 插件安装
### 通过Jetbrains官方仓库安装
1. 打开 Settings >> Plugins >> Browse repositories...

2. 在搜索框输入alibaba即可看到Alibaba Java Code Guidelines插件,点击Install进行安装,然后重启IDE生效 `注意:因为插件zip包托管在Jetbrains官方CDN上,所以是从国外的服务器进行下载,可能会出现超时的情况`

### 通过下载安装包进行安装
1. 打开[插件](https://plugins.jetbrains.com/plugin/10046-alibaba-java-coding-guidelines)页面

2. Settings >> Plugins >> Install plugin from disk...,选择刚刚下载的zip包安装,然后重启IDE

### 注意
最低支持IDEA版本为14.1(buildNumber 141.0,可以在About Intellij IDEA中查看版本信息),使用IDEA14的同学最好升级到14.1.7(<a href="https://www.jetbrains.com/idea/download/previous.html" target="_blank">历史版本传送门</a>)
插件基于JDK1.7打包,所以IDEA启动时使用的JDK版本如果是1.6的话就会报Unsupported major.minor version 51.0异常,建议大家都升级一下。
### [中文乱码解决方法](https://github.com/alibaba/p3c/issues/32#issuecomment-336762512)
1. 修改字体——Appearance&Behavior -> Appearance -> UI Options -> Name 里面设置成中文字体——如微软雅黑(microsoft yahei light)、文泉驿(linux)

2. Switch Language to English and restart.

## 插件使用
目前插件实现了开发手册中的的53条规则,大部分基于PMD实现,其中有4条规则基于IDEA实现,并且基于IDEA <a href="https://www.jetbrains.com/help/idea/code-inspection.html" target="_blank">Inspection</a>实现了实时检测功能。部分规则实现了Quick Fix功能,对于可以提供Quick Fix但没有提供的,我们会尽快实现,也欢迎有兴趣的同学加入进来一起努力。
目前插件检测有两种模式:实时检测、手动触发。
### 实时检测
实时检测功能会在开发过程中对当前文件进行检测,并以高亮的形式提示出来,同时也可以支持Quick Fix,该功能默认开启,可以通过配置关闭。
#### 结果高亮提示
<p style="text-indent:2em">检测结果高亮提示,并且鼠标放上去会弹出提示信息。</p>


#### <a href="https://www.jetbrains.com/help/idea/intention-actions.html" target="_blank">Intention</a> QuickFix功能
Alt+Enter键可呼出Intention菜单,不同的规则会提示不同信息的Quick Fix按钮

#### 关闭实时检测
在某些情况下,我们不希望对代码提示违规信息,比如我们在阅读Github开源项目代码的时候,如果界面出现一堆红色、黄色的提示,此时心里肯定是飘过一万只草泥马。这个时候我们可以通过Inspection的设置关闭实时检测功能。
1. 通过右键快速关闭(打开)所有规则的实时检测功能

2. 通过Settings >> Editor >> Inspections 进行手动设置

也可以关闭某条规则的实时检测功能或者修改提示级别。
### 代码扫描
可以通过右键菜单、Toolbar按钮、快捷键三种方式手动触发代码检测。同时结果面板中可以对部分实现了QuickFix功能的规则进行快速修复。
#### 触发扫描
在当前编辑的文件中点击右键,可以在弹出的菜单中触发对该文件的检测。

在左侧的Project目录树种点击右键,可以触发对整个工程或者选择的某个目录、文件进行检测。

如果您打开了IDE的Toolbar,也可以通过Toolbar中的按钮来触发检测,目前Toolbar的按钮触发的检测范围与您IDE当时的焦点有关,如当前编辑的文件或者是Project目录树选中的项,是不是感觉与右键菜单的检测范围类似呢。

使用快捷键(Ctrl+Shift+Alt+J)触发弹出窗口,选择检测范围;您也可自定义快捷键。


#### 扫描结果
检测结果直接使用IDEA Run Inspection By Name功能的结果界面,插件的检测结果分级为Blocker、Critical、Major。默认按等级分组,方便统计每个级别错误的数量。

默认情况我们在结果面板需要双击具体违规项才能打开对应的源文件,开启Autoscroll To Source选项,单击面板中的文件名、或者是具体的违规项的时候IDEA会自动打开对应的源文件。

#### QuickFix
对于实现Quick Fix的规则,在结果面板中可以直接一键修复 `注意:IDEA14、15可以通过左下角的灯泡进行一键修复操作。`


#### 其他
面板中其他按钮的功能大家自行探索吧,就不一一赘述了
### 代码提交时检测
1. 在提交代码框勾选Alibaba Code Guidelines选项

2. 如果有违反手册的地方会提示是否继续提交,选择取消后会自动对修改的代码进行扫描

================================================
FILE: idea-plugin/build.gradle
================================================
buildscript {
repositories {
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
maven {
url 'http://dl.bintray.com/jetbrains/intellij-plugin-service'
}
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
group 'com.alibaba.p3c.idea'
apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'maven-publish'
sourceCompatibility = 1.8
compileJava.options.encoding = 'UTF-8'
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
repositories {
jcenter()
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
testCompile group: 'junit', name: 'junit', version: '4.11'
}
}
================================================
FILE: idea-plugin/gradle/wrapper/gradle-wrapper.properties
================================================
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
================================================
FILE: idea-plugin/gradle.properties
================================================
kotlin_version=1.3.72
idea_version=2018.3
plugin_name=Alibaba Java Coding Guidelines
gradle_jetbrains_version=0.4.5
systemProp.file.encoding=UTF-8
plugin_version=2.1.0
================================================
FILE: idea-plugin/gradlew
================================================
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"
================================================
FILE: idea-plugin/gradlew.bat
================================================
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: idea-plugin/p3c-common/build.gradle
================================================
plugins {
id "org.jetbrains.intellij" version '0.4.5'
}
apply plugin: 'kotlin'
apply plugin: 'idea'
apply plugin: 'maven'
apply plugin: 'signing'
javadoc {
options.tags = ["date"]
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from 'build/docs/javadoc'
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives jar
archives javadocJar
archives sourcesJar
}
def myPlugins = []
def versionDotIndex = idea_version.indexOf('.')
def intVersion = versionDotIndex == -1 ? Integer.parseInt(idea_version) : Integer.parseInt(idea_version.substring(0, versionDotIndex))
if (intVersion >= 2019 || (intVersion < 1000 && intVersion >= 193)) {
myPlugins = ['java']
}
intellij {
version idea_version
plugins = myPlugins
pluginName plugin_name
updateSinceUntilBuild false
sandboxDirectory "$project.buildDir/idea-sandbox/$idea_version"
}
version '2.0.1'
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
dependencies {
compile group: 'org.freemarker', name: 'freemarker', version: '2.3.25-incubating'
compile 'com.alibaba.p3c:p3c-pmd:2.1.0'
compile group: 'org.javassist', name: 'javassist', version: '3.21.0-GA'
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: findProperty('ossrhUsername'), password: findProperty('ossrhPassword'))
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: findProperty('ossrhUsername'), password: findProperty('ossrhPassword'))
}
pom.project {
name 'p3c-common'
packaging 'jar'
description 'P3c Idea Plugin Common.'
url 'https://github.com/alibaba/p3c'
scm {
url 'https://github.com/alibaba/p3c'
connection 'scm:git:https://git@github.com/alibaba/p3c.git'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'junlie'
name 'Junlie'
email 'sean.caikang@gmail.com'
}
developer {
id 'ZengHou'
name 'ZengHou'
email 'fengwei1983@gmail.com'
}
}
}
}
}
}
signing {
required {
isReleaseVersion && gradle.taskGraph.hasTask("uploadArchives")
}
sign configurations.archives
}
================================================
FILE: idea-plugin/p3c-common/src/main/java/icons/P3cIcons.java
================================================
/*
* Copyright 1999-2017 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package icons;
import javax.swing.Icon;
import com.intellij.openapi.util.IconLoader;
/**
* @author caikang
* @date 2016/12/28
*/
public final class P3cIcons {
private P3cIcons() {
throw new AssertionError("icons.P3cIcons"
+ " instances for you!");
}
public static final Icon ANALYSIS_ACTION = IconLoader.getIcon("/icons/ali-ide-run.png");
public static final Icon PROJECT_INSPECTION_ON = IconLoader.getIcon("/icons/qiyong.png");
public static final Icon PROJECT_INSPECTION_OFF = IconLoader.getIcon("/icons/tingyong.png");
public static final Icon LANGUAGE = IconLoader.getIcon("/icons/language.png");
public static final Icon ALIBABA = IconLoader.getIcon("/icons/alibaba.png");
}
================================================
FILE: idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/action/AliInspectionAction.kt
================================================
/*
* Copyright 1999-2017 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.p3c.idea.action
import com.alibaba.p3c.idea.compatible.inspection.InspectionProfileService
import com.alibaba.p3c.idea.compatible.inspection.Inspections
import com.alibaba.p3c.idea.i18n.P3cBundle
import com.alibaba.p3c.idea.inspection.AliBaseInspection
import com.alibaba.p3c.idea.util.NumberConstants
import com.google.common.collect.Lists
import com.intellij.analysis.AnalysisScope
import com.intellij.analysis.AnalysisUIOptions
import com.intellij.analysis.BaseAnalysisActionDialog
import com.intellij.codeInspection.InspectionManager
import com.intellij.codeInspection.InspectionsBundle
import com.intellij.codeInspection.ex.GlobalInspectionContextImpl
import com.intellij.codeInspection.ex.InspectionManagerEx
import com.intellij.codeInspection.ex.InspectionToolWrapper
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.components.ServiceManager
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.module.Module
import com.intellij.openapi.module.ModuleUtilCore
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VfsUtilCore
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.wm.ToolWindowId
import com.intellij.openapi.wm.ToolWindowManager
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
import com.intellij.psi.PsiFileSystemItem
import com.intellij.psi.PsiManager
import java.awt.event.KeyEvent
/**
* @author caikang
* @date 2016/12/11
*/
class AliInspectionAction : AnAction() {
override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return
val analysisUIOptions = ServiceManager.getService(project, AnalysisUIOptions::class.java)!!
analysisUIOptions.GROUP_BY_SEVERITY = true
val managerEx = InspectionManager.getInstance(project) as InspectionManagerEx
val toolWrappers = Inspections.aliInspections(project) {
it.tool is AliBaseInspection
}
val psiElement = e.getData<PsiElement>(CommonDataKeys.PSI_ELEMENT)
val psiFile = e.getData<PsiFile>(CommonDataKeys.PSI_FILE)
val virtualFile = e.getData<VirtualFile>(CommonDataKeys.VIRTUAL_FILE)
val virtualFiles = e.getData<Array<VirtualFile>>(CommonDataKeys.VIRTUAL_FILE_ARRAY)
var analysisScope: AnalysisScope? = null
var projectDir = false
if (psiFile != null) {
analysisScope = AnalysisScope(psiFile)
projectDir = isBaseDir(psiFile.virtualFile, project)
} else if (virtualFiles != null && virtualFiles.size > NumberConstants.INTEGER_SIZE_OR_LENGTH_0) {
analysisScope = AnalysisScope(project, Lists.newArrayList<VirtualFile>(*virtualFiles))
projectDir = virtualFiles.any {
isBaseDir(it, project)
}
} else {
if (virtualFile != null && virtualFile.isDirectory) {
val psiDirectory = PsiManager.getInstance(p
gitextract_c6djlc1m/
├── .github/
│ └── ISSUE_TEMPLATE/
│ ├── ------.md
│ ├── bug_report.md
│ ├── feature_request.md
│ └── rule-issue-template.md
├── .gitignore
├── README.md
├── eclipse-plugin/
│ ├── .gitignore
│ ├── README.md
│ ├── README_cn.md
│ ├── com.alibaba.smartfox.eclipse.feature/
│ │ ├── build.properties
│ │ ├── feature.properties
│ │ ├── feature.xml
│ │ └── pom.xml
│ ├── com.alibaba.smartfox.eclipse.plugin/
│ │ ├── META-INF/
│ │ │ └── MANIFEST.MF
│ │ ├── build.properties
│ │ ├── plugin.xml
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── kotlin/
│ │ │ └── com/
│ │ │ └── alibaba/
│ │ │ └── smartfox/
│ │ │ └── eclipse/
│ │ │ ├── QuickFix.kt
│ │ │ ├── SmartfoxActivator.kt
│ │ │ ├── handler/
│ │ │ │ ├── CodeAnalysisHandler.kt
│ │ │ │ └── SwitchLanguageHandler.kt
│ │ │ ├── job/
│ │ │ │ ├── CodeAnalysis.kt
│ │ │ │ └── P3cMutex.kt
│ │ │ ├── message/
│ │ │ │ └── P3cBundle.kt
│ │ │ ├── pmd/
│ │ │ │ ├── RulePriority.kt
│ │ │ │ └── rule/
│ │ │ │ ├── AbstractEclipseRule.kt
│ │ │ │ ├── AvoidAccessStaticViaInstanceRule.kt
│ │ │ │ ├── AvoidUseDeprecationRule.kt
│ │ │ │ ├── MapOrSetKeyShouldOverrideHashCodeEqualsRule.kt
│ │ │ │ └── MissingOverrideAnnotationRule.kt
│ │ │ ├── ui/
│ │ │ │ ├── AllRulesPreferencePage.kt
│ │ │ │ ├── AllRulesView.kt
│ │ │ │ ├── InspectionResultTreeContentProvider.kt
│ │ │ │ ├── InspectionResultTreeLabelProvider.kt
│ │ │ │ ├── InspectionResultView.kt
│ │ │ │ ├── InspectionResults.kt
│ │ │ │ ├── QuickFixAction.kt
│ │ │ │ ├── RuleDetailComposite.kt
│ │ │ │ ├── RuleDetailView.kt
│ │ │ │ ├── Violations.kt
│ │ │ │ └── pmd/
│ │ │ │ ├── BasicLineStyleListener.kt
│ │ │ │ ├── ContentBuilder.kt
│ │ │ │ ├── FontBuilder.kt
│ │ │ │ ├── StringArranger.kt
│ │ │ │ ├── StyleExtractor.kt
│ │ │ │ ├── SyntaxData.kt
│ │ │ │ └── SyntaxManager.kt
│ │ │ └── util/
│ │ │ ├── CleanUps.kt
│ │ │ └── MarkerUtil.kt
│ │ └── resources/
│ │ ├── messages/
│ │ │ ├── P3cBundle.xml
│ │ │ └── P3cBundle_en.xml
│ │ ├── rulesets/
│ │ │ └── java/
│ │ │ ├── ali-pmd.xml
│ │ │ └── ali-ruleOnEclipse.xml
│ │ └── syntax/
│ │ └── java.properties
│ ├── com.alibaba.smartfox.eclipse.updatesite/
│ │ ├── category.xml
│ │ └── pom.xml
│ └── pom.xml
├── idea-plugin/
│ ├── .gitignore
│ ├── README.md
│ ├── README_cn.md
│ ├── build.gradle
│ ├── gradle/
│ │ └── wrapper/
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
│ ├── gradle.properties
│ ├── gradlew
│ ├── gradlew.bat
│ ├── p3c-common/
│ │ ├── build.gradle
│ │ └── src/
│ │ └── main/
│ │ ├── java/
│ │ │ └── icons/
│ │ │ └── P3cIcons.java
│ │ ├── kotlin/
│ │ │ └── com/
│ │ │ └── alibaba/
│ │ │ ├── p3c/
│ │ │ │ └── idea/
│ │ │ │ ├── action/
│ │ │ │ │ ├── AliInspectionAction.kt
│ │ │ │ │ ├── PmdGlobalInspectionContextImpl.kt
│ │ │ │ │ ├── SwitchLanguageAction.kt
│ │ │ │ │ └── ToggleProjectInspectionAction.kt
│ │ │ │ ├── compatible/
│ │ │ │ │ └── inspection/
│ │ │ │ │ ├── InspectionProfileService.kt
│ │ │ │ │ └── Inspections.kt
│ │ │ │ ├── component/
│ │ │ │ │ ├── AliProjectComponent.kt
│ │ │ │ │ └── CommonSettingsApplicationComponent.kt
│ │ │ │ ├── config/
│ │ │ │ │ ├── P3cConfig.kt
│ │ │ │ │ └── SmartFoxProjectConfig.kt
│ │ │ │ ├── ep/
│ │ │ │ │ ├── InspectionActionExtensionPoint.kt
│ │ │ │ │ └── package-info.java
│ │ │ │ ├── i18n/
│ │ │ │ │ └── P3cBundle.kt
│ │ │ │ ├── inspection/
│ │ │ │ │ ├── AliAccessToNonThreadSafeStaticFieldFromInstanceInspection.kt
│ │ │ │ │ ├── AliArrayNamingShouldHaveBracketInspection.kt
│ │ │ │ │ ├── AliBaseInspection.kt
│ │ │ │ │ ├── AliControlFlowStatementWithoutBracesInspection.kt
│ │ │ │ │ ├── AliEqualsAvoidNullInspection.kt
│ │ │ │ │ ├── AliLocalInspectionToolProvider.kt
│ │ │ │ │ ├── AliLongLiteralsEndingWithLowercaseLInspection.kt
│ │ │ │ │ ├── AliPmdInspection.kt
│ │ │ │ │ ├── AliPmdInspectionInvoker.kt
│ │ │ │ │ ├── AliWrapperTypeEqualityInspection.kt
│ │ │ │ │ ├── DelegateLocalInspectionTool.kt
│ │ │ │ │ ├── DelegatePmdInspection.kt
│ │ │ │ │ ├── PmdRuleInspectionIdentify.kt
│ │ │ │ │ ├── RuleInspectionUtils.kt
│ │ │ │ │ └── standalone/
│ │ │ │ │ ├── AliAccessStaticViaInstanceInspection.kt
│ │ │ │ │ ├── AliDeprecationInspection.kt
│ │ │ │ │ ├── AliMissingOverrideAnnotationInspection.kt
│ │ │ │ │ └── MapOrSetKeyShouldOverrideHashCodeEqualsInspection.kt
│ │ │ │ ├── pmd/
│ │ │ │ │ ├── AliPmdProcessor.kt
│ │ │ │ │ ├── SourceCodeProcessor.kt
│ │ │ │ │ └── index/
│ │ │ │ │ ├── InspectionDataSource.kt
│ │ │ │ │ └── InspectionRenderer.kt
│ │ │ │ ├── quickfix/
│ │ │ │ │ ├── AliQuickFix.kt
│ │ │ │ │ ├── AvoidStartWithDollarAndUnderLineNamingQuickFix.kt
│ │ │ │ │ ├── ClassMustHaveAuthorQuickFix.kt
│ │ │ │ │ ├── ConstantFieldShouldBeUpperCaseQuickFix.kt
│ │ │ │ │ ├── DecorateInspectionFix.kt
│ │ │ │ │ ├── LowerCamelCaseVariableNamingQuickFix.kt
│ │ │ │ │ └── VmQuietReferenceQuickFix.kt
│ │ │ │ ├── util/
│ │ │ │ │ ├── DocumentUtils.kt
│ │ │ │ │ ├── HighlightDisplayLevels.kt
│ │ │ │ │ ├── HighlightInfoTypes.kt
│ │ │ │ │ ├── HighlightSeverities.kt
│ │ │ │ │ ├── NumberConstants.kt
│ │ │ │ │ ├── ObjectConstants.kt
│ │ │ │ │ ├── ProblemsUtils.kt
│ │ │ │ │ ├── QuickFixes.kt
│ │ │ │ │ └── withLockNotInline.kt
│ │ │ │ └── vcs/
│ │ │ │ ├── AliCodeAnalysisCheckinHandler.kt
│ │ │ │ └── AliCodeAnalysisCheckinHandlerFactory.kt
│ │ │ └── smartfox/
│ │ │ └── idea/
│ │ │ └── common/
│ │ │ ├── component/
│ │ │ │ ├── AliBaseApplicationComponent.kt
│ │ │ │ └── AliBaseProjectComponent.kt
│ │ │ └── util/
│ │ │ ├── BalloonNotifications.kt
│ │ │ ├── CommonExtensions.kt
│ │ │ └── PluginVersions.kt
│ │ └── resources/
│ │ ├── messages/
│ │ │ ├── P3cBundle.xml
│ │ │ └── P3cBundle_en.xml
│ │ ├── rulesets/
│ │ │ └── java/
│ │ │ └── ali-pmd.xml
│ │ └── tpl/
│ │ └── StaticDescriptionTemplate.ftl
│ ├── p3c-idea/
│ │ ├── build.gradle
│ │ └── src/
│ │ └── main/
│ │ └── resources/
│ │ └── META-INF/
│ │ ├── p3c.xml
│ │ └── plugin.xml
│ └── settings.gradle
├── license.txt
├── p3c-formatter/
│ ├── eclipse-codestyle.xml
│ └── eclipse-codetemplate.xml
├── p3c-gitbook/
│ ├── .gitignore
│ ├── MySQL数据库/
│ │ ├── ORM映射.md
│ │ ├── SQL语句.md
│ │ ├── 建表规约.md
│ │ └── 索引规约.md
│ ├── README.md
│ ├── SUMMARY.md
│ ├── book.json
│ ├── styles/
│ │ └── website.css
│ ├── 单元测试.md
│ ├── 安全规约.md
│ ├── 工程结构/
│ │ ├── 二方库依赖.md
│ │ ├── 应用分层.md
│ │ └── 服务器.md
│ ├── 异常日志/
│ │ ├── 其他.md
│ │ ├── 异常处理.md
│ │ └── 日志规约.md
│ ├── 本手册专有名词.md
│ ├── 版本历史.md
│ └── 编程规约/
│ ├── OOP规范.md
│ ├── 代码格式.md
│ ├── 命名风格.md
│ ├── 常量定义.md
│ ├── 并发处理.md
│ ├── 控制语句.md
│ ├── 注释规约.md
│ └── 集合处理.md
└── p3c-pmd/
├── .gitignore
├── README.md
├── pom.xml
└── src/
├── main/
│ ├── java/
│ │ └── com/
│ │ └── alibaba/
│ │ └── p3c/
│ │ └── pmd/
│ │ ├── I18nResources.java
│ │ ├── fix/
│ │ │ └── FixClassTypeResolver.java
│ │ └── lang/
│ │ ├── AbstractXpathRule.java
│ │ ├── java/
│ │ │ ├── rule/
│ │ │ │ ├── AbstractAliRule.java
│ │ │ │ ├── AbstractPojoRule.java
│ │ │ │ ├── comment/
│ │ │ │ │ ├── AbstractAliCommentRule.java
│ │ │ │ │ ├── AbstractMethodOrInterfaceMethodMustUseJavadocRule.java
│ │ │ │ │ ├── AvoidCommentBehindStatementRule.java
│ │ │ │ │ ├── ClassMustHaveAuthorRule.java
│ │ │ │ │ ├── CommentsMustBeJavadocFormatRule.java
│ │ │ │ │ ├── EnumConstantsMustHaveCommentRule.java
│ │ │ │ │ └── RemoveCommentedCodeRule.java
│ │ │ │ ├── concurrent/
│ │ │ │ │ ├── AvoidCallStaticSimpleDateFormatRule.java
│ │ │ │ │ ├── AvoidConcurrentCompetitionRandomRule.java
│ │ │ │ │ ├── AvoidManuallyCreateThreadRule.java
│ │ │ │ │ ├── AvoidUseTimerRule.java
│ │ │ │ │ ├── CountDownShouldInFinallyRule.java
│ │ │ │ │ ├── ThreadLocalShouldRemoveRule.java
│ │ │ │ │ ├── ThreadPoolCreationRule.java
│ │ │ │ │ └── ThreadShouldSetNameRule.java
│ │ │ │ ├── constant/
│ │ │ │ │ ├── UndefineMagicConstantRule.java
│ │ │ │ │ └── UpperEllRule.java
│ │ │ │ ├── exception/
│ │ │ │ │ ├── AvoidReturnInFinallyRule.java
│ │ │ │ │ ├── MethodReturnWrapperTypeRule.java
│ │ │ │ │ └── TransactionMustHaveRollbackRule.java
│ │ │ │ ├── flowcontrol/
│ │ │ │ │ ├── AvoidComplexConditionRule.java
│ │ │ │ │ ├── AvoidNegationOperatorRule.java
│ │ │ │ │ ├── NeedBraceRule.java
│ │ │ │ │ └── SwitchStatementRule.java
│ │ │ │ ├── naming/
│ │ │ │ │ ├── AbstractClassShouldStartWithAbstractNamingRule.java
│ │ │ │ │ ├── ArrayNamingShouldHaveBracketRule.java
│ │ │ │ │ ├── AvoidStartWithDollarAndUnderLineNamingRule.java
│ │ │ │ │ ├── BooleanPropertyShouldNotStartWithIsRule.java
│ │ │ │ │ ├── ClassNamingShouldBeCamelRule.java
│ │ │ │ │ ├── ConstantFieldShouldBeUpperCaseRule.java
│ │ │ │ │ ├── ExceptionClassShouldEndWithExceptionRule.java
│ │ │ │ │ ├── LowerCamelCaseVariableNamingRule.java
│ │ │ │ │ ├── PackageNamingRule.java
│ │ │ │ │ ├── ServiceOrDaoClassShouldEndWithImplRule.java
│ │ │ │ │ └── TestClassShouldEndWithTestNamingRule.java
│ │ │ │ ├── oop/
│ │ │ │ │ ├── BigDecimalAvoidDoubleConstructorRule.java
│ │ │ │ │ ├── EqualsAvoidNullRule.java
│ │ │ │ │ ├── PojoMustOverrideToStringRule.java
│ │ │ │ │ ├── PojoMustUsePrimitiveFieldRule.java
│ │ │ │ │ ├── PojoNoDefaultValueRule.java
│ │ │ │ │ ├── StringConcatRule.java
│ │ │ │ │ └── WrapperTypeEqualityRule.java
│ │ │ │ ├── orm/
│ │ │ │ │ └── IbatisMethodQueryForListRule.java
│ │ │ │ ├── other/
│ │ │ │ │ ├── AvoidApacheBeanUtilsCopyRule.java
│ │ │ │ │ ├── AvoidDoubleOrFloatEqualCompareRule.java
│ │ │ │ │ ├── AvoidMissUseOfMathRandomRule.java
│ │ │ │ │ ├── AvoidNewDateGetTimeRule.java
│ │ │ │ │ ├── AvoidPatternCompileInMethodRule.java
│ │ │ │ │ ├── MethodTooLongRule.java
│ │ │ │ │ └── UseRightCaseForDateFormatRule.java
│ │ │ │ ├── set/
│ │ │ │ │ ├── ClassCastExceptionWithSubListToArrayListRule.java
│ │ │ │ │ ├── ClassCastExceptionWithToArrayRule.java
│ │ │ │ │ ├── CollectionInitShouldAssignCapacityRule.java
│ │ │ │ │ ├── ConcurrentExceptionWithModifyOriginSubListRule.java
│ │ │ │ │ ├── DontModifyInForeachCircleRule.java
│ │ │ │ │ └── UnsupportedExceptionWithModifyAsListRule.java
│ │ │ │ └── util/
│ │ │ │ ├── NodeSortUtils.java
│ │ │ │ └── NodeUtils.java
│ │ │ └── util/
│ │ │ ├── GeneratedCodeUtils.java
│ │ │ ├── NumberConstants.java
│ │ │ ├── PojoUtils.java
│ │ │ ├── SpiLoader.java
│ │ │ ├── StringAndCharConstants.java
│ │ │ ├── VariableUtils.java
│ │ │ ├── ViolationUtils.java
│ │ │ └── namelist/
│ │ │ ├── NameListConfig.java
│ │ │ ├── NameListService.java
│ │ │ └── NameListServiceImpl.java
│ │ └── vm/
│ │ └── rule/
│ │ └── other/
│ │ └── UseQuietReferenceNotationRule.java
│ ├── kotlin/
│ │ └── com/
│ │ └── alibaba/
│ │ └── p3c/
│ │ └── pmd/
│ │ └── lang/
│ │ └── java/
│ │ └── rule/
│ │ └── concurrent/
│ │ └── LockShouldWithTryFinallyRule.kt
│ └── resources/
│ ├── META-INF/
│ │ └── services/
│ │ └── com.alibaba.p3c.pmd.lang.java.util.namelist.NameListService
│ ├── messages.xml
│ ├── messages_en.xml
│ ├── namelist.properties
│ └── rulesets/
│ ├── java/
│ │ ├── ali-comment.xml
│ │ ├── ali-concurrent.xml
│ │ ├── ali-constant.xml
│ │ ├── ali-exception.xml
│ │ ├── ali-flowcontrol.xml
│ │ ├── ali-naming.xml
│ │ ├── ali-oop.xml
│ │ ├── ali-orm.xml
│ │ ├── ali-other.xml
│ │ └── ali-set.xml
│ └── vm/
│ └── ali-other.xml
└── test/
├── java/
│ └── com/
│ └── alibaba/
│ └── p3c/
│ └── pmd/
│ ├── lang/
│ │ ├── java/
│ │ │ └── rule/
│ │ │ ├── comment/
│ │ │ │ └── CommentRulesTest.java
│ │ │ ├── concurrent/
│ │ │ │ └── ConcurrentRuleTest.java
│ │ │ ├── constant/
│ │ │ │ └── ConstantRulesTest.java
│ │ │ ├── exception/
│ │ │ │ └── ExceptionRulesTest.java
│ │ │ ├── flowcontrol/
│ │ │ │ └── FlowControlRuleTest.java
│ │ │ ├── naming/
│ │ │ │ └── NamingRulesTest.java
│ │ │ ├── oop/
│ │ │ │ └── OopRuleTest.java
│ │ │ ├── orm/
│ │ │ │ └── OrmRulesTest.java
│ │ │ ├── other/
│ │ │ │ ├── OtherRulesTest.java
│ │ │ │ └── UseRightCaseForDateFormatRuleTest.java
│ │ │ └── set/
│ │ │ └── SetRulesTest.java
│ │ └── vm/
│ │ └── rule/
│ │ └── other/
│ │ └── OtherRulesTest.java
│ └── testframework/
│ ├── ExtendRuleTst.java
│ └── ExtendSimpleAggregatorTst.java
└── resources/
└── com/
└── alibaba/
└── p3c/
└── pmd/
└── lang/
├── java/
│ └── rule/
│ ├── comment/
│ │ └── xml/
│ │ ├── AbstractMethodOrInterfaceMethodMustUseJavadocRule.xml
│ │ ├── AvoidCommentBehindStatementRule.xml
│ │ ├── ClassMustHaveAuthorRule.xml
│ │ ├── CommentsMustBeJavadocFormatRule.xml
│ │ ├── EnumConstantsMustHaveCommentRule.xml
│ │ └── RemoveCommentedCodeRule.xml
│ ├── concurrent/
│ │ └── xml/
│ │ ├── AvoidCallStaticSimpleDateFormatRule.xml
│ │ ├── AvoidConcurrentCompetitionRandomRule.xml
│ │ ├── AvoidManuallyCreateThreadRule.xml
│ │ ├── AvoidUseTimerRule.xml
│ │ ├── CountDownShouldInFinallyRule.xml
│ │ ├── LockShouldWithTryFinallyRule.xml
│ │ ├── ThreadLocalShouldRemoveRule.xml
│ │ ├── ThreadPoolCreationRule.xml
│ │ └── ThreadShouldSetNameRule.xml
│ ├── constant/
│ │ └── xml/
│ │ ├── UndefineMagicConstantRule.xml
│ │ └── UpperEllRule.xml
│ ├── exception/
│ │ └── xml/
│ │ ├── AvoidReturnInFinallyRule.xml
│ │ ├── MethodReturnWrapperTypeRule.xml
│ │ └── TransactionMustHaveRollbackRule.xml
│ ├── flowcontrol/
│ │ └── xml/
│ │ ├── AvoidComplexConditionRule.xml
│ │ ├── AvoidNegationOperatorRule.xml
│ │ ├── NeedBraceRule.xml
│ │ └── SwitchStatementRule.xml
│ ├── naming/
│ │ └── xml/
│ │ ├── AbstractClassShouldStartWithAbstractNamingRule.xml
│ │ ├── ArrayNamingShouldHaveBracketRule.xml
│ │ ├── AvoidStartWithDollarAndUnderLineNamingRule.xml
│ │ ├── BooleanPropertyShouldNotStartWithIsRule.xml
│ │ ├── ClassNamingShouldBeCamelRule.xml
│ │ ├── ConstantFieldShouldBeUpperCaseRule.xml
│ │ ├── ExceptionClassShouldEndWithExceptionRule.xml
│ │ ├── LowerCamelCaseVariableNamingRule.xml
│ │ ├── PackageNamingRule.xml
│ │ ├── ServiceOrDaoClassShouldEndWithImplRule.xml
│ │ └── TestClassShouldEndWithTestNamingRule.xml
│ ├── oop/
│ │ └── xml/
│ │ ├── BigDecimalAvoidDoubleConstructorRule.xml
│ │ ├── EqualsAvoidNullRule.xml
│ │ ├── PojoMustOverrideToStringRule.xml
│ │ ├── PojoMustUsePrimitiveFieldRule.xml
│ │ ├── PojoNoDefaultValueRule.xml
│ │ ├── StringConcatRule.xml
│ │ └── WrapperTypeEqualityRule.xml
│ ├── orm/
│ │ └── xml/
│ │ └── IbatisMethodQueryForListRule.xml
│ ├── other/
│ │ ├── java/
│ │ │ └── UseRightCaseForDateFormatRuleExam.java
│ │ └── xml/
│ │ ├── AvoidApacheBeanUtilsCopyRule.xml
│ │ ├── AvoidDoubleOrFloatEqualCompareRule.xml
│ │ ├── AvoidMissUseOfMathRandomRule.xml
│ │ ├── AvoidNewDateGetTimeRule.xml
│ │ ├── AvoidPatternCompileInMethodRule.xml
│ │ ├── MethodTooLongRule.xml
│ │ └── UseRightCaseForDateFormatRule.xml
│ └── set/
│ └── xml/
│ ├── ClassCastExceptionWithSubListToArrayListRule.xml
│ ├── ClassCastExceptionWithToArrayRule.xml
│ ├── CollectionInitShouldAssignCapacityRule.xml
│ ├── ConcurrentExceptionWithModifyOriginSubListRule.xml
│ ├── DontModifyInForeachCircleRule.xml
│ └── UnsupportedExceptionWithModifyAsListRule.xml
└── vm/
└── rule/
└── other/
└── xml/
└── UseQuietReferenceNotationRule.xml
SYMBOL INDEX (401 symbols across 90 files)
FILE: idea-plugin/p3c-common/src/main/java/icons/P3cIcons.java
class P3cIcons (line 26) | public final class P3cIcons {
method P3cIcons (line 27) | private P3cIcons() {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/I18nResources.java
class I18nResources (line 37) | public class I18nResources {
method changeLanguage (line 46) | public static ResourceBundle changeLanguage(String language) {
method changeLanguage (line 51) | public static ResourceBundle changeLanguage(Locale locale) {
method getMessage (line 60) | public static String getMessage(String key) {
method getMessage (line 72) | public static String getMessage(String key, Object... params) {
method getMessageWithExceptionHandled (line 80) | public static String getMessageWithExceptionHandled(String key) {
class XmlResourceBundle (line 92) | public static class XmlResourceBundle extends ResourceBundle {
method XmlResourceBundle (line 95) | XmlResourceBundle(InputStream stream) throws IOException {
method handleGetObject (line 100) | @Override
method getKeys (line 105) | @Override
class XmlControl (line 116) | public static class XmlControl extends Control {
method getFormats (line 117) | @Override
method getFallbackLocale (line 125) | @Override
method newBundle (line 130) | @Override
method getInputStream (line 162) | private InputStream getInputStream(ClassLoader loader, String resour...
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/fix/FixClassTypeResolver.java
class FixClassTypeResolver (line 82) | @Generated("from pmd")
method FixClassTypeResolver (line 150) | public FixClassTypeResolver() {
method FixClassTypeResolver (line 154) | public FixClassTypeResolver(ClassLoader classLoader) {
method visit (line 160) | @Override
method visit (line 184) | @Override
method visit (line 199) | @Override
method visit (line 206) | @Override
method visit (line 213) | @Override
method visit (line 219) | @Override
method visit (line 225) | @Override
method visit (line 231) | @Override
method visit (line 261) | @Override
method visit (line 268) | @Override
method visit (line 275) | @Override
method visit (line 287) | @Override
method visit (line 294) | @Override
method visit (line 301) | @Override
method visit (line 307) | @Override
method visit (line 314) | @Override
method visit (line 326) | @Override
method visit (line 332) | @Override
method visit (line 338) | @Override
method visit (line 345) | @Override
method visit (line 352) | @Override
method visit (line 359) | @Override
method visit (line 365) | @Override
method visit (line 371) | @Override
method visit (line 377) | @Override
method visit (line 385) | @Override
method visit (line 392) | @Override
method visit (line 399) | @Override
method visit (line 406) | @Override
method visit (line 413) | @Override
method visit (line 420) | @Override
method visit (line 431) | @Override
method visit (line 438) | @Override
method visit (line 445) | @Override
method visit (line 457) | @Override
method visit (line 469) | @Override
method visit (line 477) | @Override
method visit (line 483) | @Override
method visit (line 489) | @Override
method visit (line 514) | @Override
method visit (line 527) | @Override
method visit (line 534) | @Override
method visit (line 541) | @Override
method visit (line 548) | @Override
method rollupTypeUnary (line 560) | private void rollupTypeUnary(TypeNode typeNode) {
method rollupTypeUnaryNumericPromotion (line 576) | private void rollupTypeUnaryNumericPromotion(TypeNode typeNode) {
method rollupTypeBinaryNumericPromotion (line 600) | private void rollupTypeBinaryNumericPromotion(TypeNode typeNode) {
method populateType (line 644) | private void populateType(TypeNode node, String className) {
method classNameExists (line 698) | @Override
method loadClass (line 711) | @Override
method processOnDemand (line 720) | private Class<?> processOnDemand(String qualifiedName) {
method getClassName (line 730) | private String getClassName(ASTCompilationUnit node) {
method populateImports (line 748) | private void populateImports(ASTCompilationUnit node) {
method populateClassName (line 766) | private void populateClassName(ASTCompilationUnit node, String classNa...
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/AbstractXpathRule.java
class AbstractXpathRule (line 27) | public abstract class AbstractXpathRule extends XPathRule {
method setDescription (line 28) | @Override
method setMessage (line 33) | @Override
method addViolationWithMessage (line 38) | @Override
method addViolationWithMessage (line 43) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/AbstractAliRule.java
class AbstractAliRule (line 36) | public abstract class AbstractAliRule extends AbstractJavaRule {
method visit (line 43) | @Override
method setDescription (line 63) | @Override
method setMessage (line 68) | @Override
method addViolationWithMessage (line 73) | @Override
method addViolationWithMessage (line 78) | @Override
method resolveType (line 84) | private void resolveType(ASTCompilationUnit node, Object data) {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/AbstractPojoRule.java
class AbstractPojoRule (line 31) | public abstract class AbstractPojoRule extends AbstractAliRule {
method visit (line 41) | @Override
method hasPojoInJavaFile (line 55) | private boolean hasPojoInJavaFile(ASTCompilationUnit node) {
method isPojo (line 66) | protected boolean isPojo(ASTClassOrInterfaceDeclaration node) {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/comment/AbstractAliCommentRule.java
class AbstractAliCommentRule (line 27) | public class AbstractAliCommentRule extends AbstractCommentRule {
method setDescription (line 28) | @Override
method setMessage (line 33) | @Override
method addViolationWithMessage (line 38) | @Override
method addViolationWithMessage (line 43) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/comment/AbstractMethodOrInterfaceMethodMustUseJavadocRule.java
class AbstractMethodOrInterfaceMethodMustUseJavadocRule (line 42) | public class AbstractMethodOrInterfaceMethodMustUseJavadocRule extends A...
method visit (line 55) | @Override
method checkMethodCommentFormat (line 98) | public void checkMethodCommentFormat(ASTMethodDeclaration method, Obje...
method visit (line 156) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/comment/AvoidCommentBehindStatementRule.java
class AvoidCommentBehindStatementRule (line 41) | public class AvoidCommentBehindStatementRule extends AbstractAliCommentR...
method visit (line 43) | @Override
method orderedCommentsAndExpressions (line 72) | protected SortedMap<Integer, Node> orderedCommentsAndExpressions(ASTCo...
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/comment/ClassMustHaveAuthorRule.java
class ClassMustHaveAuthorRule (line 40) | public class ClassMustHaveAuthorRule extends AbstractAliCommentRule {
method visit (line 55) | @Override
method visit (line 64) | @Override
method visit (line 81) | @Override
method visit (line 87) | @Override
method orderedCommentsAndDeclarations (line 94) | @Override
method addDeclarations (line 114) | private void addDeclarations(SortedMap<Integer, Node> map, List<? exte...
method checkAuthorComment (line 126) | public void checkAuthorComment(AbstractJavaNode decl, Object data) {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/comment/CommentsMustBeJavadocFormatRule.java
class CommentsMustBeJavadocFormatRule (line 54) | public class CommentsMustBeJavadocFormatRule extends AbstractAliCommentR...
method visit (line 58) | @Override
method visit (line 65) | @Override
method visit (line 89) | @Override
method visit (line 96) | @Override
method visit (line 103) | @Override
method visit (line 110) | @Override
method checkComment (line 117) | private void checkComment(AbstractJavaAccessNode decl, Object data, Me...
method assignCommentsToDeclarations (line 125) | @Override
method orderedComments (line 156) | protected SortedMap<Integer, Node> orderedComments(ASTCompilationUnit ...
method isCommentOneLineBefore (line 184) | private boolean isCommentOneLineBefore(SortedMap<Integer, Node> items,...
type MessageMaker (line 228) | interface MessageMaker {
method make (line 234) | String make();
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/comment/EnumConstantsMustHaveCommentRule.java
class EnumConstantsMustHaveCommentRule (line 37) | public class EnumConstantsMustHaveCommentRule extends AbstractAliComment...
method visit (line 39) | @Override
method orderedCommentsAndEnumDeclarations (line 66) | private SortedMap<Integer, Node> orderedCommentsAndEnumDeclarations(AS...
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/comment/RemoveCommentedCodeRule.java
class RemoveCommentedCodeRule (line 43) | public class RemoveCommentedCodeRule extends AbstractAliCommentRule {
method visit (line 62) | @Override
method checkCommentsBetweenDeclarations (line 69) | protected void checkCommentsBetweenDeclarations(ASTCompilationUnit cUn...
method scanCommentedCode (line 127) | protected CommentPatternEnum scanCommentedCode(String content) {
method orderedCommentsAndDeclarations (line 148) | @Override
method isCommentBefore (line 177) | private boolean isCommentBefore(Comment n1, Node n2) {
type CommentPatternEnum (line 182) | enum CommentPatternEnum {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/concurrent/AvoidCallStaticSimpleDateFormatRule.java
class AvoidCallStaticSimpleDateFormatRule (line 50) | public class AvoidCallStaticSimpleDateFormatRule extends AbstractAliRule {
method visit (line 53) | @Override
method handleMethod (line 63) | private void handleMethod(ASTMethodDeclaration methodDeclaration, Obje...
method handleFlowNode (line 84) | private void handleFlowNode(Stack<Node> stack, Set<String> localSimple...
method getExpressName (line 133) | private String getExpressName(ASTPrimaryExpression primaryExpression) {
method isStaticSimpleDateFormatCall (line 138) | private boolean isStaticSimpleDateFormatCall(
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/concurrent/AvoidConcurrentCompetitionRandomRule.java
class AvoidConcurrentCompetitionRandomRule (line 43) | public class AvoidConcurrentCompetitionRandomRule extends AbstractAliRule {
method visit (line 52) | @Override
method checkMathRandom (line 80) | private void checkMathRandom(List<ASTMethodDeclaration> methodDeclarat...
method checkRandom (line 101) | private void checkRandom(ASTFieldDeclaration fieldDeclaration, List<AS...
method hasThread (line 120) | private boolean hasThread(ASTExtendsList extendsList) {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/concurrent/AvoidManuallyCreateThreadRule.java
class AvoidManuallyCreateThreadRule (line 54) | public class AvoidManuallyCreateThreadRule extends AbstractAliRule {
method visit (line 58) | @Override
method isAddShutdownHook (line 96) | private boolean isAddShutdownHook(ASTAllocationExpression node) {
method isInStaticInitializer (line 105) | private boolean isInStaticInitializer(ASTAllocationExpression node) {
method threadFactoryVariable (line 110) | private boolean threadFactoryVariable(ASTAllocationExpression node) {
method isInNewThreadMethod (line 119) | private boolean isInNewThreadMethod(ASTAllocationExpression node) {
method isInPrimaryOrProtectedMethod (line 136) | private boolean isInPrimaryOrProtectedMethod(ASTAllocationExpression n...
method returnThread (line 142) | private boolean returnThread(ASTMethodDeclaration methodDeclaration) {
method addViolationAndReturn (line 148) | private Object addViolationAndReturn(ASTAllocationExpression node, Obj...
method checkForNamingClass (line 153) | private boolean checkForNamingClass(ASTAllocationExpression node) {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/concurrent/AvoidUseTimerRule.java
class AvoidUseTimerRule (line 33) | public class AvoidUseTimerRule extends AbstractAliRule {
method visit (line 34) | @Override
method visit (line 40) | @Override
method checkType (line 50) | private void checkType(AbstractJavaTypeNode node, Object data) {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/concurrent/CountDownShouldInFinallyRule.java
class CountDownShouldInFinallyRule (line 39) | public class CountDownShouldInFinallyRule extends AbstractAliRule {
method visit (line 43) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/concurrent/ThreadLocalShouldRemoveRule.java
class ThreadLocalShouldRemoveRule (line 42) | public class ThreadLocalShouldRemoveRule extends AbstractAliRule {
method visit (line 50) | @Override
method checkThreadLocalWithInitalValue (line 65) | private boolean checkThreadLocalWithInitalValue(ASTFieldDeclaration fi...
method checkThreadLocal (line 81) | private void checkThreadLocal(ASTFieldDeclaration fieldDeclaration, AS...
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/concurrent/ThreadPoolCreationRule.java
class ThreadPoolCreationRule (line 39) | public class ThreadPoolCreationRule extends AbstractAliRule {
method visit (line 50) | @Override
method checkInitStatement (line 78) | private boolean checkInitStatement(Token token, Info info) {
method getFullAssignStatement (line 104) | private String getFullAssignStatement(final Token token) {
class Info (line 117) | class Info {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/concurrent/ThreadShouldSetNameRule.java
class ThreadShouldSetNameRule (line 50) | public class ThreadShouldSetNameRule extends AbstractAliRule {
method visit (line 58) | @Override
method visit (line 76) | @Override
method checkThreadPoolExecutor (line 81) | private Object checkThreadPoolExecutor(ASTAllocationExpression node, O...
method checkSchedulePoolExecutor (line 93) | private Object checkSchedulePoolExecutor(ASTAllocationExpression node,...
method checkThreadFactoryArgument (line 105) | private boolean checkThreadFactoryArgument(ASTExpression expression) {
method isThreadFactoryLambda (line 123) | private boolean isThreadFactoryLambda(ASTLambdaExpression lambdaExpres...
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/constant/UndefineMagicConstantRule.java
class UndefineMagicConstantRule (line 41) | public class UndefineMagicConstantRule extends AbstractAliRule {
method visit (line 57) | @Override
method inBlackList (line 88) | private boolean inBlackList(ASTLiteral literal) {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/constant/UpperEllRule.java
class UpperEllRule (line 29) | public class UpperEllRule extends AbstractAliRule {
method visit (line 32) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/exception/AvoidReturnInFinallyRule.java
class AvoidReturnInFinallyRule (line 32) | public class AvoidReturnInFinallyRule extends AbstractXpathRule {
method AvoidReturnInFinallyRule (line 35) | public AvoidReturnInFinallyRule() {
method addViolation (line 39) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/exception/MethodReturnWrapperTypeRule.java
class MethodReturnWrapperTypeRule (line 41) | public class MethodReturnWrapperTypeRule extends AbstractAliRule {
method visit (line 51) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/exception/TransactionMustHaveRollbackRule.java
class TransactionMustHaveRollbackRule (line 36) | public class TransactionMustHaveRollbackRule extends AbstractAliRule {
method visit (line 51) | @Override
method shouldSkip (line 87) | private boolean shouldSkip(List<ASTMemberValuePair> memberValuePairLis...
method getSiblingForType (line 112) | private <T> T getSiblingForType(ASTAnnotation node, Class<T> clz) {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/flowcontrol/AvoidComplexConditionRule.java
class AvoidComplexConditionRule (line 31) | public class AvoidComplexConditionRule extends AbstractXpathRule {
method AvoidComplexConditionRule (line 36) | public AvoidComplexConditionRule() {
method addViolation (line 40) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/flowcontrol/AvoidNegationOperatorRule.java
class AvoidNegationOperatorRule (line 31) | public class AvoidNegationOperatorRule extends AbstractXpathRule {
method AvoidNegationOperatorRule (line 37) | public AvoidNegationOperatorRule() {
method addViolation (line 41) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/flowcontrol/NeedBraceRule.java
class NeedBraceRule (line 36) | public class NeedBraceRule extends AbstractAliRule {
method visit (line 41) | @Override
method visit (line 59) | @Override
method visit (line 67) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/flowcontrol/SwitchStatementRule.java
class SwitchStatementRule (line 30) | public class SwitchStatementRule extends AbstractAliRule {
method visit (line 33) | @Override
method checkDefault (line 48) | private void checkDefault(ASTSwitchStatement node, Object data) {
method checkFallThrough (line 61) | private void checkFallThrough(ASTSwitchStatement node, Object data) {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/naming/AbstractClassShouldStartWithAbstractNamingRule.java
class AbstractClassShouldStartWithAbstractNamingRule (line 31) | public class AbstractClassShouldStartWithAbstractNamingRule extends Abst...
method AbstractClassShouldStartWithAbstractNamingRule (line 35) | public AbstractClassShouldStartWithAbstractNamingRule() {
method addViolation (line 39) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/naming/ArrayNamingShouldHaveBracketRule.java
class ArrayNamingShouldHaveBracketRule (line 30) | public class ArrayNamingShouldHaveBracketRule extends AbstractXpathRule {
method ArrayNamingShouldHaveBracketRule (line 34) | public ArrayNamingShouldHaveBracketRule() {
method addViolation (line 38) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/naming/AvoidStartWithDollarAndUnderLineNamingRule.java
class AvoidStartWithDollarAndUnderLineNamingRule (line 32) | public class AvoidStartWithDollarAndUnderLineNamingRule extends Abstract...
method visit (line 38) | @Override
method visit (line 46) | @Override
method visit (line 54) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/naming/BooleanPropertyShouldNotStartWithIsRule.java
class BooleanPropertyShouldNotStartWithIsRule (line 32) | public class BooleanPropertyShouldNotStartWithIsRule extends AbstractXpa...
method BooleanPropertyShouldNotStartWithIsRule (line 38) | public BooleanPropertyShouldNotStartWithIsRule() {
method addViolation (line 42) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/naming/ClassNamingShouldBeCamelRule.java
class ClassNamingShouldBeCamelRule (line 34) | public class ClassNamingShouldBeCamelRule extends AbstractAliRule {
method visit (line 42) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/naming/ConstantFieldShouldBeUpperCaseRule.java
class ConstantFieldShouldBeUpperCaseRule (line 37) | public class ConstantFieldShouldBeUpperCaseRule extends AbstractAliRule {
method visit (line 44) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/naming/ExceptionClassShouldEndWithExceptionRule.java
class ExceptionClassShouldEndWithExceptionRule (line 34) | public class ExceptionClassShouldEndWithExceptionRule extends AbstractAl...
method visit (line 38) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/naming/LowerCamelCaseVariableNamingRule.java
class LowerCamelCaseVariableNamingRule (line 39) | public class LowerCamelCaseVariableNamingRule extends AbstractAliRule {
method visit (line 44) | @Override
method visit (line 72) | @Override
method visit (line 83) | @Override
method variableNamingStartOrEndWithDollarAndUnderLine (line 89) | private boolean variableNamingStartOrEndWithDollarAndUnderLine(String ...
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/naming/PackageNamingRule.java
class PackageNamingRule (line 31) | public class PackageNamingRule extends AbstractXpathRule {
method PackageNamingRule (line 35) | public PackageNamingRule() {
method addViolation (line 39) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/naming/ServiceOrDaoClassShouldEndWithImplRule.java
class ServiceOrDaoClassShouldEndWithImplRule (line 31) | public class ServiceOrDaoClassShouldEndWithImplRule extends AbstractXpat...
method ServiceOrDaoClassShouldEndWithImplRule (line 37) | public ServiceOrDaoClassShouldEndWithImplRule() {
method addViolation (line 41) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/naming/TestClassShouldEndWithTestNamingRule.java
class TestClassShouldEndWithTestNamingRule (line 34) | public class TestClassShouldEndWithTestNamingRule extends AbstractJUnitR...
method visit (line 37) | @Override
method isInInnerClassOrInterface (line 63) | private boolean isInInnerClassOrInterface(ASTMethodDeclaration md) {
method setDescription (line 68) | @Override
method setMessage (line 73) | @Override
method addViolationWithMessage (line 78) | @Override
method addViolationWithMessage (line 83) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/oop/BigDecimalAvoidDoubleConstructorRule.java
class BigDecimalAvoidDoubleConstructorRule (line 36) | public class BigDecimalAvoidDoubleConstructorRule extends AbstractAliRule {
method visit (line 42) | @Override
method addViolation (line 63) | @Override
method isDoubleLiteral (line 69) | private boolean isDoubleLiteral(ASTPrimaryPrefix node) {
method isDoubleVariable (line 74) | private boolean isDoubleVariable(ASTPrimaryPrefix node) {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/oop/EqualsAvoidNullRule.java
class EqualsAvoidNullRule (line 43) | public class EqualsAvoidNullRule extends AbstractAliRule {
method visit (line 57) | @Override
method callerIsLiteral (line 107) | private boolean callerIsLiteral(Node equalsInvocation) {
method getInvocationName (line 115) | private String getInvocationName(AbstractJavaNode javaNode) {
method addRuleViolation (line 128) | private void addRuleViolation(Object data, Node invocation) {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/oop/PojoMustOverrideToStringRule.java
class PojoMustOverrideToStringRule (line 37) | public class PojoMustOverrideToStringRule extends AbstractPojoRule {
method visit (line 60) | @Override
method checkForExtend (line 82) | private void checkForExtend(ASTClassOrInterfaceDeclaration node, Objec...
method withLombokAnnotation (line 111) | private boolean withLombokAnnotation(ASTClassOrInterfaceDeclaration no...
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/oop/PojoMustUsePrimitiveFieldRule.java
class PojoMustUsePrimitiveFieldRule (line 41) | public class PojoMustUsePrimitiveFieldRule extends AbstractPojoRule {
method visit (line 43) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/oop/PojoNoDefaultValueRule.java
class PojoNoDefaultValueRule (line 37) | public class PojoNoDefaultValueRule extends AbstractPojoRule {
method visit (line 39) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/oop/StringConcatRule.java
class StringConcatRule (line 43) | public class StringConcatRule extends AbstractAliRule {
method visit (line 49) | @Override
method visit (line 55) | @Override
method visit (line 61) | @Override
method checkStringConcat (line 74) | private void checkStringConcat(Node node, Object data, Class nodeClass) {
method addViolation (line 133) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/oop/WrapperTypeEqualityRule.java
class WrapperTypeEqualityRule (line 33) | public class WrapperTypeEqualityRule extends AbstractAliRule {
method visit (line 35) | @Override
method isArrayLength (line 66) | private boolean isArrayLength(ASTPrimaryExpression expression) {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/orm/IbatisMethodQueryForListRule.java
class IbatisMethodQueryForListRule (line 47) | public class IbatisMethodQueryForListRule extends AbstractAliRule {
method visit (line 58) | @Override
method visitAstClassOrInterfaceDeclaration (line 75) | private void visitAstClassOrInterfaceDeclaration(ASTClassOrInterfaceDe...
method getSqlMapFields (line 92) | private Set<String> getSqlMapFields(List<Node> fieldDeclarations) {
method hasSqlMapClientImport (line 110) | private boolean hasSqlMapClientImport(List<ASTImportDeclaration> impor...
method visitPrimaryExpression (line 128) | private void visitPrimaryExpression(ASTPrimaryExpression node, Object ...
method sqlMapClientField (line 173) | private boolean sqlMapClientField(ASTFieldDeclaration node) {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/other/AvoidApacheBeanUtilsCopyRule.java
class AvoidApacheBeanUtilsCopyRule (line 31) | public class AvoidApacheBeanUtilsCopyRule extends AbstractXpathRule {
method AvoidApacheBeanUtilsCopyRule (line 36) | public AvoidApacheBeanUtilsCopyRule() {
method addViolation (line 40) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/other/AvoidDoubleOrFloatEqualCompareRule.java
class AvoidDoubleOrFloatEqualCompareRule (line 14) | public class AvoidDoubleOrFloatEqualCompareRule extends AbstractAliRule {
method visit (line 20) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/other/AvoidMissUseOfMathRandomRule.java
class AvoidMissUseOfMathRandomRule (line 31) | public class AvoidMissUseOfMathRandomRule extends AbstractXpathRule {
method AvoidMissUseOfMathRandomRule (line 39) | public AvoidMissUseOfMathRandomRule() {
method addViolation (line 43) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/other/AvoidNewDateGetTimeRule.java
class AvoidNewDateGetTimeRule (line 30) | public class AvoidNewDateGetTimeRule extends AbstractXpathRule {
method AvoidNewDateGetTimeRule (line 41) | public AvoidNewDateGetTimeRule() {
method addViolation (line 45) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/other/AvoidPatternCompileInMethodRule.java
class AvoidPatternCompileInMethodRule (line 33) | public class AvoidPatternCompileInMethodRule extends AbstractXpathRule {
method AvoidPatternCompileInMethodRule (line 42) | public AvoidPatternCompileInMethodRule() {
method addViolation (line 46) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/other/MethodTooLongRule.java
class MethodTooLongRule (line 49) | public class MethodTooLongRule extends AbstractAliRule {
method visit (line 59) | @Override
method visit (line 65) | @Override
method orderedCommentsAndExpressions (line 105) | protected SortedMap<Integer, Node> orderedCommentsAndExpressions(ASTCo...
method getCommentLineCount (line 124) | private int getCommentLineCount(ASTMethodDeclaration methodDecl) {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/other/UseRightCaseForDateFormatRule.java
class UseRightCaseForDateFormatRule (line 36) | public class UseRightCaseForDateFormatRule extends AbstractXpathRule {
method UseRightCaseForDateFormatRule (line 45) | public UseRightCaseForDateFormatRule() {
method addViolation (line 49) | @Override
method checkNode (line 60) | private void checkNode(Node argNode, Object data) {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/set/ClassCastExceptionWithSubListToArrayListRule.java
class ClassCastExceptionWithSubListToArrayListRule (line 35) | public class ClassCastExceptionWithSubListToArrayListRule extends Abstra...
method visit (line 41) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/set/ClassCastExceptionWithToArrayRule.java
class ClassCastExceptionWithToArrayRule (line 36) | public class ClassCastExceptionWithToArrayRule extends AbstractAliRule {
method visit (line 41) | @Override
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/set/CollectionInitShouldAssignCapacityRule.java
class CollectionInitShouldAssignCapacityRule (line 35) | public class CollectionInitShouldAssignCapacityRule extends AbstractAliR...
method visit (line 43) | @Override
method visitByCollections (line 56) | private void visitByCollections(ASTClassOrInterfaceDeclaration node, O...
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/set/ConcurrentExceptionWithModifyOriginSubListRule.java
class ConcurrentExceptionWithModifyOriginSubListRule (line 35) | public class ConcurrentExceptionWithModifyOriginSubListRule extends Abst...
method visit (line 46) | @Override
method getBeforeSubListVal (line 89) | private String getBeforeSubListVal(String image) {
method checkBlockNodesValid (line 101) | private boolean checkBlockNodesValid(String variableName, Node item) {
method judgeName (line 118) | private boolean judgeName(String name, String variableName) {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/set/DontModifyInForeachCircleRule.java
class DontModifyInForeachCircleRule (line 35) | public class DontModifyInForeachCircleRule extends AbstractAliRule {
method visit (line 44) | @Override
method judgeName (line 78) | private boolean judgeName(String name, String variableName) {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/set/UnsupportedExceptionWithModifyAsListRule.java
class UnsupportedExceptionWithModifyAsListRule (line 37) | public class UnsupportedExceptionWithModifyAsListRule extends AbstractAl...
method visit (line 48) | @Override
method checkBlockNodesValid (line 103) | private boolean checkBlockNodesValid(String variableName, Node item) {
method judgeName (line 120) | private boolean judgeName(String name, String variableName) {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/util/NodeSortUtils.java
class NodeSortUtils (line 29) | public class NodeSortUtils {
method addNodesToSortedMap (line 37) | public static void addNodesToSortedMap(SortedMap<Integer, Node> map, L...
method generateIndex (line 48) | public static int generateIndex(Node node) {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/util/NodeUtils.java
class NodeUtils (line 33) | public class NodeUtils {
method isParentOrSelf (line 38) | public static boolean isParentOrSelf(Node descendant, Node ancestor) {
method isWrapperType (line 58) | public static boolean isWrapperType(ASTPrimaryExpression expression) {
method isConstant (line 69) | public static boolean isConstant(ASTFieldDeclaration field) {
method getNodeType (line 73) | public static Class<?> getNodeType(AbstractJavaAccessTypeNode node) {
method isLockStatementExpression (line 77) | public static boolean isLockStatementExpression(ASTStatementExpression...
method isUnLockStatementExpression (line 81) | public static boolean isUnLockStatementExpression(ASTStatementExpressi...
method isLockTypeAndMethod (line 85) | private static boolean isLockTypeAndMethod(ASTStatementExpression stat...
method isLockNode (line 94) | public static boolean isLockNode(Node node) {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/util/GeneratedCodeUtils.java
class GeneratedCodeUtils (line 27) | public class GeneratedCodeUtils {
method isGenerated (line 32) | public static boolean isGenerated(ASTCompilationUnit compilationUnit) {
method isGenerated (line 47) | public static boolean isGenerated(String content) {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/util/NumberConstants.java
class NumberConstants (line 22) | public final class NumberConstants {
method NumberConstants (line 23) | private NumberConstants() {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/util/PojoUtils.java
class PojoUtils (line 30) | public class PojoUtils {
method PojoUtils (line 34) | private PojoUtils() {
method isPojo (line 37) | public static boolean isPojo(String klass) {
method isPojo (line 49) | public static boolean isPojo(ASTClassOrInterfaceDeclaration node) {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/util/SpiLoader.java
class SpiLoader (line 27) | public class SpiLoader {
method getInstance (line 30) | @SuppressWarnings("unchecked")
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/util/StringAndCharConstants.java
class StringAndCharConstants (line 22) | public final class StringAndCharConstants {
method StringAndCharConstants (line 23) | private StringAndCharConstants(){
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/util/VariableUtils.java
class VariableUtils (line 10) | public class VariableUtils {
method getVariableName (line 11) | public static String getVariableName(AbstractJavaAccessNode typeNode) {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/util/ViolationUtils.java
class ViolationUtils (line 29) | public class ViolationUtils {
method addViolationWithPrecisePosition (line 30) | public static void addViolationWithPrecisePosition(AbstractRule rule, ...
method addViolationWithPrecisePosition (line 34) | public static void addViolationWithPrecisePosition(AbstractRule rule, ...
method addViolation (line 49) | private static void addViolation(AbstractRule rule, Node node, Object ...
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/util/namelist/NameListConfig.java
class NameListConfig (line 24) | public class NameListConfig {
method getNameListService (line 27) | private static NameListService getNameListService() {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/util/namelist/NameListService.java
type NameListService (line 25) | public interface NameListService {
method getNameList (line 32) | List<String> getNameList(String className,String name);
method getNameMap (line 44) | <K, V> Map<K, V> getNameMap(String className,String name,Class<K> kCla...
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/util/namelist/NameListServiceImpl.java
class NameListServiceImpl (line 31) | public class NameListServiceImpl implements NameListService {
method initProperties (line 37) | private static Properties initProperties() {
method getNameList (line 48) | @Override
method getNameMap (line 55) | @Override
class LinkedProperties (line 63) | private static class LinkedProperties extends Properties {
method put (line 66) | @Override
method getSize (line 72) | public int getSize() {
FILE: p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/vm/rule/other/UseQuietReferenceNotationRule.java
class UseQuietReferenceNotationRule (line 38) | public class UseQuietReferenceNotationRule extends AbstractXpathRule {
method UseQuietReferenceNotationRule (line 53) | public UseQuietReferenceNotationRule() {
method evaluate (line 57) | @Override
method addViolation (line 75) | @Override
method getIdentifyName (line 82) | private String getIdentifyName(AbstractVmNode node) {
method checkMacro (line 100) | private boolean checkMacro(Node node) {
FILE: p3c-pmd/src/test/java/com/alibaba/p3c/pmd/lang/java/rule/comment/CommentRulesTest.java
class CommentRulesTest (line 27) | public class CommentRulesTest extends SimpleAggregatorTst {
method setUp (line 31) | @Override
FILE: p3c-pmd/src/test/java/com/alibaba/p3c/pmd/lang/java/rule/concurrent/ConcurrentRuleTest.java
class ConcurrentRuleTest (line 27) | public class ConcurrentRuleTest extends SimpleAggregatorTst {
method setUp (line 30) | @Override
FILE: p3c-pmd/src/test/java/com/alibaba/p3c/pmd/lang/java/rule/constant/ConstantRulesTest.java
class ConstantRulesTest (line 27) | public class ConstantRulesTest extends SimpleAggregatorTst {
method setUp (line 31) | @Override
FILE: p3c-pmd/src/test/java/com/alibaba/p3c/pmd/lang/java/rule/exception/ExceptionRulesTest.java
class ExceptionRulesTest (line 27) | public class ExceptionRulesTest extends SimpleAggregatorTst {
method setUp (line 30) | @Override
FILE: p3c-pmd/src/test/java/com/alibaba/p3c/pmd/lang/java/rule/flowcontrol/FlowControlRuleTest.java
class FlowControlRuleTest (line 27) | public class FlowControlRuleTest extends SimpleAggregatorTst {
method setUp (line 31) | @Override
FILE: p3c-pmd/src/test/java/com/alibaba/p3c/pmd/lang/java/rule/naming/NamingRulesTest.java
class NamingRulesTest (line 27) | public class NamingRulesTest extends SimpleAggregatorTst {
method setUp (line 30) | @Override
FILE: p3c-pmd/src/test/java/com/alibaba/p3c/pmd/lang/java/rule/oop/OopRuleTest.java
class OopRuleTest (line 27) | public class OopRuleTest extends SimpleAggregatorTst {
method setUp (line 32) | @Override
FILE: p3c-pmd/src/test/java/com/alibaba/p3c/pmd/lang/java/rule/orm/OrmRulesTest.java
class OrmRulesTest (line 27) | public class OrmRulesTest extends SimpleAggregatorTst {
method setUp (line 30) | @Override
FILE: p3c-pmd/src/test/java/com/alibaba/p3c/pmd/lang/java/rule/other/OtherRulesTest.java
class OtherRulesTest (line 28) | public class OtherRulesTest extends SimpleAggregatorTst {
method setUp (line 32) | @Override
FILE: p3c-pmd/src/test/java/com/alibaba/p3c/pmd/lang/java/rule/other/UseRightCaseForDateFormatRuleTest.java
class UseRightCaseForDateFormatRuleTest (line 13) | public class UseRightCaseForDateFormatRuleTest extends ExtendRuleTst {
method testExam1 (line 15) | @Test
FILE: p3c-pmd/src/test/java/com/alibaba/p3c/pmd/lang/java/rule/set/SetRulesTest.java
class SetRulesTest (line 26) | public class SetRulesTest extends SimpleAggregatorTst {
method setUp (line 30) | @Override
FILE: p3c-pmd/src/test/java/com/alibaba/p3c/pmd/lang/vm/rule/other/OtherRulesTest.java
class OtherRulesTest (line 27) | public class OtherRulesTest extends SimpleAggregatorTst {
method setUp (line 31) | @Override
FILE: p3c-pmd/src/test/java/com/alibaba/p3c/pmd/testframework/ExtendRuleTst.java
class ExtendRuleTst (line 20) | public class ExtendRuleTst extends RuleTst {
method runTest (line 23) | public void runTest(Rule rule, String examFilePath, String expectedVio...
method extractTestsFromJavaFile (line 35) | public TestDescriptor extractTestsFromJavaFile(Rule rule) {
method extractTestsFromJavaFile (line 44) | public TestDescriptor extractTestsFromJavaFile(Rule rule, String javaF...
method extractTestsFromJavaFile (line 48) | public TestDescriptor extractTestsFromJavaFile(Rule rule, String javaF...
method getExpectedLineNumbers (line 80) | public List<Integer> getExpectedLineNumbers(String lineNumbers) {
FILE: p3c-pmd/src/test/java/com/alibaba/p3c/pmd/testframework/ExtendSimpleAggregatorTst.java
class ExtendSimpleAggregatorTst (line 12) | public class ExtendSimpleAggregatorTst extends SimpleAggregatorTst {
FILE: p3c-pmd/src/test/resources/com/alibaba/p3c/pmd/lang/java/rule/other/java/UseRightCaseForDateFormatRuleExam.java
class UseRightCaseForDateFormatRuleExam (line 11) | public class UseRightCaseForDateFormatRuleExam {
method exam1 (line 15) | public void exam1() {
method exam2 (line 51) | public void exam2(String formatStr) {
method exam3 (line 57) | public void exam3(){
Condensed preview — 329 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,182K chars).
[
{
"path": ".github/ISSUE_TEMPLATE/------.md",
"chars": 102,
"preview": "---\nname: 规约问题模板\nabout: 规约问题请使用该模板\ntitle: ''\nlabels: ''\nassignees: ''\n\n---\n\n## 规约原文\n\n## 问题描述\n\n## 修改建议\n"
},
{
"path": ".github/ISSUE_TEMPLATE/bug_report.md",
"chars": 834,
"preview": "---\nname: Bug report\nabout: Create a report to help us improve\ntitle: ''\nlabels: ''\nassignees: ''\n\n---\n\n**Describe the b"
},
{
"path": ".github/ISSUE_TEMPLATE/feature_request.md",
"chars": 595,
"preview": "---\nname: Feature request\nabout: Suggest an idea for this project\ntitle: ''\nlabels: ''\nassignees: ''\n\n---\n\n**Is your fea"
},
{
"path": ".github/ISSUE_TEMPLATE/rule-issue-template.md",
"chars": 166,
"preview": "---\nname: Rule issue template\nabout: Rule issue please use this template.\ntitle: ''\nlabels: ''\nassignees: ''\n\n---\n\n## Ru"
},
{
"path": ".gitignore",
"chars": 886,
"preview": "# Gradle\nbuild\n.gradle\n\ntestdata/\n# Java gitignore #\n.class\n.log\n\n# Package Files #\n\n*.war\n*.ear\n\n#hsf files\nconfigurati"
},
{
"path": "README.md",
"chars": 3082,
"preview": "# P3C\n\n最新版本:黄山版(2022.2.3发布)\n\n[](https://www.apache"
},
{
"path": "eclipse-plugin/.gitignore",
"chars": 834,
"preview": "# Gradle\nbuild\n.gradle\n\ntestdata/\n# Java gitignore #\n.class\n.log\n\n# Package Files #\n\n*.war\n*.ear\n*.gradle\n\n#hsf files\nco"
},
{
"path": "eclipse-plugin/README.md",
"chars": 846,
"preview": "# Eclipse Plugin\n---\n## <font color=\"green\">Prepare</font>\n- Eclipse Juno+ \n- maven3.+\n- JDK 1.7+\n\n## <font color=\"green"
},
{
"path": "eclipse-plugin/README_cn.md",
"chars": 1973,
"preview": "> 首先非常感谢大家对插件的支持与意见,Eclipse的功能相对来说比较简单,希望有更多的同学加入进来一起完善。\n\n## 插件安装\n环境:JDK1.8,Eclipse4+。有同学遇到过这样的情况,安装插件重启后,发现没有对应的菜单项,从日志"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.feature/build.properties",
"chars": 220,
"preview": "bin.includes = feature.xml,\\\n feature.properties,\\\n smartfox.png\nsrc.includes = build.proper"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.feature/feature.properties",
"chars": 963,
"preview": "feature.label = Ali-CodeAnalysis\nfeature.provider_name = Alibaba\nfeature.update_site_name = Alibaba IDE Portal\n\ndescript"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.feature/feature.xml",
"chars": 1412,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<feature\n id=\"com.alibaba.smartfox.eclipse.feature\"\n label=\"%featur"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.feature/pom.xml",
"chars": 598,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apach"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/META-INF/MANIFEST.MF",
"chars": 1845,
"preview": "Manifest-Version: 1.0\nBundle-ManifestVersion: 2\nBundle-Name: com.alibaba.smartfox.eclipse.plugin\nBundle-SymbolicName: co"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/build.properties",
"chars": 398,
"preview": "bin.includes = .,\\\n META-INF/,\\\n plugin.xml,\\\n icons/,\\\n target/"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/plugin.xml",
"chars": 6122,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?eclipse version=\"3.4\"?>\n<plugin>\n <extension\n id=\"SmartFoxViews\"\n "
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/pom.xml",
"chars": 4208,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apach"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/QuickFix.kt",
"chars": 4026,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/SmartfoxActivator.kt",
"chars": 4360,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/handler/CodeAnalysisHandler.kt",
"chars": 3957,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/handler/SwitchLanguageHandler.kt",
"chars": 1888,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/job/CodeAnalysis.kt",
"chars": 5404,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/job/P3cMutex.kt",
"chars": 993,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/message/P3cBundle.kt",
"chars": 1133,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/pmd/RulePriority.kt",
"chars": 1119,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/pmd/rule/AbstractEclipseRule.kt",
"chars": 6153,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/pmd/rule/AvoidAccessStaticViaInstanceRule.kt",
"chars": 4665,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/pmd/rule/AvoidUseDeprecationRule.kt",
"chars": 4181,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/pmd/rule/MapOrSetKeyShouldOverrideHashCodeEqualsRule.kt",
"chars": 5495,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/pmd/rule/MissingOverrideAnnotationRule.kt",
"chars": 3271,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/AllRulesPreferencePage.kt",
"chars": 1148,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/AllRulesView.kt",
"chars": 1585,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/InspectionResultTreeContentProvider.kt",
"chars": 2092,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/InspectionResultTreeLabelProvider.kt",
"chars": 2476,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/InspectionResultView.kt",
"chars": 8694,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/InspectionResults.kt",
"chars": 3153,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/QuickFixAction.kt",
"chars": 4016,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/RuleDetailComposite.kt",
"chars": 2807,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/RuleDetailView.kt",
"chars": 2729,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/Violations.kt",
"chars": 2285,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/pmd/BasicLineStyleListener.kt",
"chars": 681,
"preview": "package com.alibaba.smartfox.eclipse.ui.pmd\n\nimport org.eclipse.swt.custom.LineStyleEvent\nimport org.eclipse.swt.custom."
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/pmd/ContentBuilder.kt",
"chars": 4740,
"preview": "package com.alibaba.smartfox.eclipse.ui.pmd\n\nimport net.sourceforge.pmd.lang.Language\nimport org.eclipse.swt.SWT\nimport "
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/pmd/FontBuilder.kt",
"chars": 549,
"preview": "package com.alibaba.smartfox.eclipse.ui.pmd\n\nimport org.eclipse.swt.graphics.Font\nimport org.eclipse.swt.graphics.TextSt"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/pmd/StringArranger.kt",
"chars": 1261,
"preview": "package com.alibaba.smartfox.eclipse.ui.pmd\n\nimport net.sourceforge.pmd.util.StringUtil\nimport java.util.ArrayList\n\n/**\n"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/pmd/StyleExtractor.kt",
"chars": 10451,
"preview": "package com.alibaba.smartfox.eclipse.ui.pmd\n\nimport net.sourceforge.pmd.util.StringUtil\nimport org.eclipse.swt.SWT\nimpor"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/pmd/SyntaxData.kt",
"chars": 1041,
"preview": "package com.alibaba.smartfox.eclipse.ui.pmd\n\n/**\n * This class contains information for syntax coloring and styling for "
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/ui/pmd/SyntaxManager.kt",
"chars": 2810,
"preview": "package com.alibaba.smartfox.eclipse.ui.pmd\n\nimport org.eclipse.swt.custom.StyledText\nimport org.eclipse.swt.events.Modi"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/util/CleanUps.kt",
"chars": 14835,
"preview": "// =====================================================================\n//\n// Copyright (C) 2012 - 2016, Philip Graf\n//"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/kotlin/com/alibaba/smartfox/eclipse/util/MarkerUtil.kt",
"chars": 4807,
"preview": "// =====================================================================\n//\n// Copyright (C) 2012 - 2016, Philip Graf\n//"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/resources/messages/P3cBundle.xml",
"chars": 1978,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE properties SYSTEM \"http://java.sun.com/dtd/properties.d"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/resources/messages/P3cBundle_en.xml",
"chars": 3012,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE properties SYSTEM \"http://java.sun.com/dtd/properties.d"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/resources/rulesets/java/ali-pmd.xml",
"chars": 820,
"preview": "<?xml version=\"1.0\"?>\n\n<ruleset xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" name=\"alibaba-pmd\"\n xmlns="
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/resources/rulesets/java/ali-ruleOnEclipse.xml",
"chars": 1899,
"preview": "<?xml version=\"1.0\"?>\n\n<ruleset xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" name=\"AlibabaRuleOnEclipse\"\n "
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.plugin/src/main/resources/syntax/java.properties",
"chars": 480,
"preview": "# This file contains the syntax data for .java files\ncomment=//\nstringstart=\"\nstringend=\"\nmultilinecommentstart=/*\nmulti"
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.updatesite/category.xml",
"chars": 364,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<site>\n <description url=\"https://p3c.alibaba.com/plugin/eclipse/update\">\n "
},
{
"path": "eclipse-plugin/com.alibaba.smartfox.eclipse.updatesite/pom.xml",
"chars": 604,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apach"
},
{
"path": "eclipse-plugin/pom.xml",
"chars": 8485,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apach"
},
{
"path": "idea-plugin/.gitignore",
"chars": 815,
"preview": "# Gradle\nbuild\n.gradle\n\ntestdata/\n# Java gitignore #\n.class\n.log\n\n# Package Files #\n\n*.war\n*.ear\n\n#hsf files\nconfigurati"
},
{
"path": "idea-plugin/README.md",
"chars": 2450,
"preview": "# Idea Plugin \n---\n## <font color=\"green\">Prepare</font>\n- Project JDK: 1.7+\n- Gradle: 3.0+(Require JDK1.8+ for gradle)\n"
},
{
"path": "idea-plugin/README_cn.md",
"chars": 4109,
"preview": "> 首先非常感谢大家对插件的支持与意见,英文版的文档还是略为简单,这里详细介绍一下插件的安装使用。\n\n## 插件安装\n### 通过Jetbrains官方仓库安装\n1. 打开 Settings >> Plugins >> Browse rep"
},
{
"path": "idea-plugin/build.gradle",
"chars": 908,
"preview": "buildscript {\n repositories {\n maven {\n url \"https://oss.sonatype.org/content/repositories/snapshot"
},
{
"path": "idea-plugin/gradle/wrapper/gradle-wrapper.properties",
"chars": 200,
"preview": "distributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributi"
},
{
"path": "idea-plugin/gradle.properties",
"chars": 169,
"preview": "kotlin_version=1.3.72\nidea_version=2018.3\nplugin_name=Alibaba Java Coding Guidelines\ngradle_jetbrains_version=0.4.5\nsyst"
},
{
"path": "idea-plugin/gradlew",
"chars": 5770,
"preview": "#!/usr/bin/env sh\n\n#\n# Copyright 2015 the original author or authors.\n#\n# Licensed under the Apache License, Version 2.0"
},
{
"path": "idea-plugin/gradlew.bat",
"chars": 2954,
"preview": "@rem\n@rem Copyright 2015 the original author or authors.\n@rem\n@rem Licensed under the Apache License, Version 2.0 (the \""
},
{
"path": "idea-plugin/p3c-common/build.gradle",
"chars": 3113,
"preview": "plugins {\n id \"org.jetbrains.intellij\" version '0.4.5'\n}\napply plugin: 'kotlin'\napply plugin: 'idea'\napply plugin: 'm"
},
{
"path": "idea-plugin/p3c-common/src/main/java/icons/P3cIcons.java",
"chars": 1340,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/action/AliInspectionAction.kt",
"chars": 8756,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/action/PmdGlobalInspectionContextImpl.kt",
"chars": 15378,
"preview": "package com.alibaba.p3c.idea.action\n\nimport com.alibaba.p3c.idea.component.AliProjectComponent\nimport com.alibaba.p3c.id"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/action/SwitchLanguageAction.kt",
"chars": 1913,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/action/ToggleProjectInspectionAction.kt",
"chars": 2366,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/compatible/inspection/InspectionProfileService.kt",
"chars": 4989,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/compatible/inspection/Inspections.kt",
"chars": 2553,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/component/AliProjectComponent.kt",
"chars": 5436,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/component/CommonSettingsApplicationComponent.kt",
"chars": 1357,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/config/P3cConfig.kt",
"chars": 1993,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/config/SmartFoxProjectConfig.kt",
"chars": 1290,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/ep/InspectionActionExtensionPoint.kt",
"chars": 1434,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/ep/package-info.java",
"chars": 101,
"preview": "/**\n * extension point\n *\n * @author caikang\n * @date 2017/06/19\n */\npackage com.alibaba.p3c.idea.ep;"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/i18n/P3cBundle.kt",
"chars": 1394,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/inspection/AliAccessToNonThreadSafeStaticFieldFromInstanceInspection.kt",
"chars": 1914,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/inspection/AliArrayNamingShouldHaveBracketInspection.kt",
"chars": 2864,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/inspection/AliBaseInspection.kt",
"chars": 1954,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/inspection/AliControlFlowStatementWithoutBracesInspection.kt",
"chars": 2323,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/inspection/AliEqualsAvoidNullInspection.kt",
"chars": 4918,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/inspection/AliLocalInspectionToolProvider.kt",
"chars": 8770,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/inspection/AliLongLiteralsEndingWithLowercaseLInspection.kt",
"chars": 2741,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/inspection/AliPmdInspection.kt",
"chars": 3392,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/inspection/AliPmdInspectionInvoker.kt",
"chars": 6737,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/inspection/AliWrapperTypeEqualityInspection.kt",
"chars": 6620,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/inspection/DelegateLocalInspectionTool.kt",
"chars": 3049,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/inspection/DelegatePmdInspection.kt",
"chars": 2435,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/inspection/PmdRuleInspectionIdentify.kt",
"chars": 739,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/inspection/RuleInspectionUtils.kt",
"chars": 7828,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/inspection/standalone/AliAccessStaticViaInstanceInspection.kt",
"chars": 5814,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/inspection/standalone/AliDeprecationInspection.kt",
"chars": 5207,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/inspection/standalone/AliMissingOverrideAnnotationInspection.kt",
"chars": 6149,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/inspection/standalone/MapOrSetKeyShouldOverrideHashCodeEqualsInspection.kt",
"chars": 7588,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/pmd/AliPmdProcessor.kt",
"chars": 4242,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/pmd/SourceCodeProcessor.kt",
"chars": 11050,
"preview": "/**\n * BSD-style license; for more info see http://pmd.sourceforge.net/license.html\n */\n\npackage com.alibaba.p3c.idea.pm"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/pmd/index/InspectionDataSource.kt",
"chars": 1240,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/pmd/index/InspectionRenderer.kt",
"chars": 1611,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/quickfix/AliQuickFix.kt",
"chars": 3374,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/quickfix/AvoidStartWithDollarAndUnderLineNamingQuickFix.kt",
"chars": 1697,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/quickfix/ClassMustHaveAuthorQuickFix.kt",
"chars": 2974,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/quickfix/ConstantFieldShouldBeUpperCaseQuickFix.kt",
"chars": 2444,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/quickfix/DecorateInspectionFix.kt",
"chars": 1277,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/quickfix/LowerCamelCaseVariableNamingQuickFix.kt",
"chars": 2050,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/quickfix/VmQuietReferenceQuickFix.kt",
"chars": 1450,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/util/DocumentUtils.kt",
"chars": 2051,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/util/HighlightDisplayLevels.kt",
"chars": 1102,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/util/HighlightInfoTypes.kt",
"chars": 1316,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/util/HighlightSeverities.kt",
"chars": 1085,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/util/NumberConstants.kt",
"chars": 865,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/util/ObjectConstants.kt",
"chars": 959,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/util/ProblemsUtils.kt",
"chars": 5768,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/util/QuickFixes.kt",
"chars": 1943,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/util/withLockNotInline.kt",
"chars": 1037,
"preview": "package com.alibaba.p3c.idea.util\n\nimport com.intellij.openapi.progress.ProcessCanceledException\nimport java.util.concur"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/vcs/AliCodeAnalysisCheckinHandler.kt",
"chars": 8828,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/vcs/AliCodeAnalysisCheckinHandlerFactory.kt",
"chars": 1167,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/smartfox/idea/common/component/AliBaseApplicationComponent.kt",
"chars": 1104,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/smartfox/idea/common/component/AliBaseProjectComponent.kt",
"chars": 1176,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/smartfox/idea/common/util/BalloonNotifications.kt",
"chars": 4632,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/smartfox/idea/common/util/CommonExtensions.kt",
"chars": 988,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/kotlin/com/alibaba/smartfox/idea/common/util/PluginVersions.kt",
"chars": 1821,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "idea-plugin/p3c-common/src/main/resources/messages/P3cBundle.xml",
"chars": 5436,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE properties SYSTEM \"http://java.sun.com/dtd/properties.d"
},
{
"path": "idea-plugin/p3c-common/src/main/resources/messages/P3cBundle_en.xml",
"chars": 7187,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE properties SYSTEM \"http://java.sun.com/dtd/properties.d"
},
{
"path": "idea-plugin/p3c-common/src/main/resources/rulesets/java/ali-pmd.xml",
"chars": 1045,
"preview": "<?xml version=\"1.0\"?>\n\n<ruleset xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" name=\"alibaba-pmd\"\n xmlns="
},
{
"path": "idea-plugin/p3c-common/src/main/resources/tpl/StaticDescriptionTemplate.ftl",
"chars": 243,
"preview": "<#ftl output_format=\"HTML\">\n<html>\n<body>\n<span style=\"color:orange\">\n <pre>${message}<#if description??><br>${descri"
},
{
"path": "idea-plugin/p3c-idea/build.gradle",
"chars": 824,
"preview": "plugins {\n id \"org.jetbrains.intellij\" version '0.4.5'\n}\napply plugin: 'kotlin'\napply plugin: 'idea'\n\ndef myPlugins ="
},
{
"path": "idea-plugin/p3c-idea/src/main/resources/META-INF/p3c.xml",
"chars": 2878,
"preview": "<idea-plugin>\n <application-components>\n <component>\n <implementation-class>com.alibaba.p3c.idea.co"
},
{
"path": "idea-plugin/p3c-idea/src/main/resources/META-INF/plugin.xml",
"chars": 4469,
"preview": "<idea-plugin>\n <id>com.alibaba.p3c.smartfox</id>\n <name>Alibaba Java Coding Guidelines</name>\n <description>Ali"
},
{
"path": "idea-plugin/settings.gradle",
"chars": 40,
"preview": "include 'p3c-idea'\ninclude 'p3c-common'\n"
},
{
"path": "license.txt",
"chars": 10896,
"preview": "Apache License\nVersion 2.0, January 2004\nhttp://www.apache.org/licenses/\n\nTERMS AND CONDITIONS FOR USE, REPRODUCTION, AN"
},
{
"path": "p3c-formatter/eclipse-codestyle.xml",
"chars": 46898,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<profiles version=\"12\">\n <profile kind=\"CodeFormatterProfile\" "
},
{
"path": "p3c-formatter/eclipse-codetemplate.xml",
"chars": 4834,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><templates><template autoinsert=\"true\" context=\"gettercomment_cont"
},
{
"path": "p3c-gitbook/.gitignore",
"chars": 352,
"preview": "# Node rules:\n## Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)\n.grunt\n\n## Dependen"
},
{
"path": "p3c-gitbook/MySQL数据库/ORM映射.md",
"chars": 1432,
"preview": "## (四) ORM映射\n1. 【强制】在表查询中,一律不要使用 * 作为查询的字段列表,需要哪些字段必须明确写明。 \n<br><span style=\"color:orange\">说明</span>:1)增加查询分析器解析成本。2)增减字"
},
{
"path": "p3c-gitbook/MySQL数据库/SQL语句.md",
"chars": 1524,
"preview": "## (三) SQL语句 \n1. 【强制】不要使用count(列名)或count(常量)来替代count(*),count(*)是SQL92定义的标准统计行数的语法,跟数据库无关,跟NULL和非NULL无关。 \n<br><span styl"
},
{
"path": "p3c-gitbook/MySQL数据库/建表规约.md",
"chars": 2216,
"preview": "# 五、MySQL数据库\n## (一) 建表规约\n1. 【强制】表达是与否概念的字段,必须使用is_xxx的方式命名,数据类型是unsigned tinyint( 1表示是,0表示否)。 \n<br><span style=\"color:or"
},
{
"path": "p3c-gitbook/MySQL数据库/索引规约.md",
"chars": 2222,
"preview": "## (二) 索引规约\n1. 【强制】业务上具有唯一特性的字段,即使是多个字段的组合,也必须建成唯一索引。 \n<br><span style=\"color:orange\">说明</span>:不要以为唯一索引影响了insert速度,这个速度"
},
{
"path": "p3c-gitbook/README.md",
"chars": 1010,
"preview": "## <center>前言</center>\n\n 《阿里巴巴Java开发手册》是阿里巴巴集团技术团队的集体智慧结晶和经验总结,经历了多次大规模一线实战的检验及不断的完善,系统化地整理成册,回馈给"
},
{
"path": "p3c-gitbook/SUMMARY.md",
"chars": 680,
"preview": "# Summary\n\n* [前言](README.md)\n* 一、编程规约\n - [(一)命名风格](编程规约/命名风格.md)\n - [(二)常量定义](编程规约/常量定义.md)\n - [(三)代码格式](编程规约/代码格式.md"
},
{
"path": "p3c-gitbook/book.json",
"chars": 278,
"preview": "{\n \"styles\": {\n \"website\": \"styles/website.css\"\n },\n\n \"plugins\": [\n \"book-summary-scroll-position-saver\",\n \""
},
{
"path": "p3c-gitbook/styles/website.css",
"chars": 47,
"preview": ".gitbook-link {\n display: none !important;\n}"
},
{
"path": "p3c-gitbook/单元测试.md",
"chars": 2367,
"preview": "## 三、单元测试 \n1. 【强制】好的单元测试必须遵守AIR原则。 \n<br><span style=\"color:orange\">说明</span>:单元测试在线上运行时,感觉像空气(AIR)一样并不存在,但在测试质量的保障上,却是非常"
},
{
"path": "p3c-gitbook/安全规约.md",
"chars": 1068,
"preview": "## 四、安全规约 \n1. 【强制】隶属于用户个人的页面或者功能必须进行权限控制校验。 \n<br><span style=\"color:orange\">说明</span>:防止没有做水平权限校验就可随意访问、修改、删除别人的数据,比如查看他"
},
{
"path": "p3c-gitbook/工程结构/二方库依赖.md",
"chars": 1996,
"preview": "## (二) 二方库依赖\n\n1. 【强制】定义GAV遵从以下规则: \n1) `G`roupID格式:com.{公司/BU }.业务线.[子业务线],最多4级。 \n<span style=\"color:orange\">说明</span>"
},
{
"path": "p3c-gitbook/工程结构/应用分层.md",
"chars": 1289,
"preview": "# 六、工程结构\n## (一) 应用分层 \n\n1. 【推荐】图中默认上层依赖于下层,箭头关系表示可直接依赖,如:开放接口层可以依赖于Web层,也可以直接依赖于Service层,依此类推:\n  服务器\n1. 【推荐】高并发服务器建议调小TCP协议的`time_wait`超时时间。 说明:操作系统默认240秒后,才会关闭处于`time_wait`状态的连接,在高并发访问下,服务器端会因为处于`time_wait`的连接"
},
{
"path": "p3c-gitbook/异常日志/其他.md",
"chars": 1149,
"preview": "## (三) 其它 \n1. 【强制】在使用正则表达式时,利用好其预编译功能,可以有效加快正则匹配速度。 \n<br><span style=\"color:orange\">说明</span>:不要在方法体内定义:Pattern pattern "
},
{
"path": "p3c-gitbook/异常日志/异常处理.md",
"chars": 2752,
"preview": "# 二、异常日志 \n## (一) 异常处理 \n1. 【强制】Java 类库中定义的可以通过预检查方式规避的RuntimeException异常不应该通过catch 的方式来处理,比如:NullPointerException,IndexOu"
},
{
"path": "p3c-gitbook/异常日志/日志规约.md",
"chars": 2035,
"preview": "## (二) 日志规约 \n1. 【强制】应用中不可直接使用日志系统(Log4j、Logback)中的API,而应依赖使用日志框架SLF4J中的API,使用门面模式的日志框架,有利于维护和各个类的日志处理方式统一。 \n<pre>\nimport"
},
{
"path": "p3c-gitbook/本手册专有名词.md",
"chars": 678,
"preview": "## 附2:本手册专有名词\n1. POJO(Plain Ordinary Java Object): 在本手册中,POJO专指只有setter / getter / toString的简单类,包括DO/DTO/BO/VO等。 \n2. GAV"
},
{
"path": "p3c-gitbook/版本历史.md",
"chars": 823,
"preview": "## 附1:版本历史\n| 版本号 | 更新日期 | 备注 |\n| ------------- |:-------------| :----- |\n| 1.0.0 | 2017.2.9 | 阿里巴巴集团正式对外发布 | \n| 1.0."
},
{
"path": "p3c-gitbook/编程规约/OOP规范.md",
"chars": 4359,
"preview": "## (四) OOP规约 \n\n1. 【强制】避免通过一个类的对象引用访问此类的静态变量或静态方法,无谓增加编译器解析成本,直接用**类名**来访问即可。 \n2. 【强制】所有的覆写方法,必须加@Override注解。 \n<br><span "
},
{
"path": "p3c-gitbook/编程规约/代码格式.md",
"chars": 2699,
"preview": "## (三)代码格式\n1. 【强制】大括号的使用约定。如果是大括号内为空,则简洁地写成`{}`即可,不需要换行;如果是非空代码块则:\n<br>1) 左大括号前不换行。\n<br>2) 左大括号后换行。\n<br>3) 右大括号前换行。\n<br>"
},
{
"path": "p3c-gitbook/编程规约/命名风格.md",
"chars": 3590,
"preview": "# 一、编程规约\n##(一)命名风格\n\n1. 【强制】代码中的命名均不能以<strong>下划线或美元符号</strong>开始,也不能以<strong>下划线或美元符号</strong>结束。\n <br><span style=\"col"
},
{
"path": "p3c-gitbook/编程规约/常量定义.md",
"chars": 1348,
"preview": "## (二)常量定义\n\n1. 【强制】不允许任何魔法值(即未经预先定义的常量)直接出现在代码中。\n<br><span style=\"color:red\">反例</span>:\n```\nString key = \"Id#taobao_\" + "
},
{
"path": "p3c-gitbook/编程规约/并发处理.md",
"chars": 3546,
"preview": "## (六) 并发处理 \n1. 【强制】获取单例对象需要保证线程安全,其中的方法也要保证线程安全。 \n<br><span style=\"color:orange\">说明</span>:资源驱动类、工具类、单例工厂类都需要注意。 \n2. 【强"
},
{
"path": "p3c-gitbook/编程规约/控制语句.md",
"chars": 2414,
"preview": "## (七) 控制语句 \n1. 【强制】在一个switch块内,每个case要么通过break/return等来终止,要么注释说明程序将继续执行到哪一个case为止;在一个switch块内,都必须包含一个default语句并且放在最后,即使"
},
{
"path": "p3c-gitbook/编程规约/注释规约.md",
"chars": 1615,
"preview": "## (八) 注释规约\n\n1. 【强制】类、类属性、类方法的注释必须使用Javadoc规范,使用/**内容*/格式,不得使用// xxx方式。 \n<br><span style=\"color:orange\">说明</span>:在IDE编辑"
},
{
"path": "p3c-gitbook/编程规约/集合处理.md",
"chars": 4964,
"preview": "## (五) 集合处理 \n1. 【强制】关于`hashCode`和`equals`的处理,遵循如下规则: \n<br>1) 只要重写`equals`,就必须重写`hashCode`。 \n<br>2) 因为Set存储的是不重复的对象,依据`ha"
},
{
"path": "p3c-pmd/.gitignore",
"chars": 841,
"preview": "# reference to https://github.com/github/gitignore\n\ntestdata/\n# Java gitignore #\n.class\n.log\n\n# Package Files #\n\n*.war\n*"
},
{
"path": "p3c-pmd/README.md",
"chars": 19479,
"preview": "# P3C-PMD\n\n## <font color=\"green\">Build requirements</font>\n- JDK 1.7+\n- Maven 3\n\n## <font color=\"green\">Use as dependen"
},
{
"path": "p3c-pmd/pom.xml",
"chars": 8716,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/I18nResources.java",
"chars": 5769,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/fix/FixClassTypeResolver.java",
"chars": 29368,
"preview": "/**\n * BSD-style license; for more info see http://pmd.sourceforge.net/license.html\n */\npackage com.alibaba.p3c.pmd.fix;"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/AbstractXpathRule.java",
"chars": 1657,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/AbstractAliRule.java",
"chars": 3330,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/AbstractPojoRule.java",
"chars": 2020,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/comment/AbstractAliCommentRule.java",
"chars": 1710,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/comment/AbstractMethodOrInterfaceMethodMustUseJavadocRule.java",
"chars": 7077,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/comment/AvoidCommentBehindStatementRule.java",
"chars": 3723,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/comment/ClassMustHaveAuthorRule.java",
"chars": 5055,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/comment/CommentsMustBeJavadocFormatRule.java",
"chars": 9375,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/comment/EnumConstantsMustHaveCommentRule.java",
"chars": 3062,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/comment/RemoveCommentedCodeRule.java",
"chars": 7614,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/concurrent/AvoidCallStaticSimpleDateFormatRule.java",
"chars": 6842,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/concurrent/AvoidConcurrentCompetitionRandomRule.java",
"chars": 5602,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/concurrent/AvoidManuallyCreateThreadRule.java",
"chars": 7724,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/concurrent/AvoidUseTimerRule.java",
"chars": 2016,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/concurrent/CountDownShouldInFinallyRule.java",
"chars": 2547,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/concurrent/ThreadLocalShouldRemoveRule.java",
"chars": 4227,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/concurrent/ThreadPoolCreationRule.java",
"chars": 5000,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/concurrent/ThreadShouldSetNameRule.java",
"chars": 6156,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/constant/UndefineMagicConstantRule.java",
"chars": 4749,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/constant/UpperEllRule.java",
"chars": 1549,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/exception/AvoidReturnInFinallyRule.java",
"chars": 1567,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/exception/MethodReturnWrapperTypeRule.java",
"chars": 5670,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/exception/TransactionMustHaveRollbackRule.java",
"chars": 5041,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/flowcontrol/AvoidComplexConditionRule.java",
"chars": 1728,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/flowcontrol/AvoidNegationOperatorRule.java",
"chars": 1715,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/flowcontrol/NeedBraceRule.java",
"chars": 2874,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/flowcontrol/SwitchStatementRule.java",
"chars": 3425,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/naming/AbstractClassShouldStartWithAbstractNamingRule.java",
"chars": 1862,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/naming/ArrayNamingShouldHaveBracketRule.java",
"chars": 1595,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/naming/AvoidStartWithDollarAndUnderLineNamingRule.java",
"chars": 2537,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/naming/BooleanPropertyShouldNotStartWithIsRule.java",
"chars": 2109,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
},
{
"path": "p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/rule/naming/ClassNamingShouldBeCamelRule.java",
"chars": 2206,
"preview": "/*\n * Copyright 1999-2017 Alibaba Group.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you ma"
}
]
// ... and 129 more files (download for full content)
About this extraction
This page contains the full source code of the alibaba/p3c GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 329 files (1.1 MB), approximately 284.0k tokens, and a symbol index with 401 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.