Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wangsun300
p3c
提交
6ab9ac35
P
p3c
项目概览
wangsun300
/
p3c
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
p3c
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6ab9ac35
编写于
10月 18, 2017
作者:
骏
骏烈
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Redefine constant in class (NumberConstants ObjectConstants...)
上级
e7e6fcc8
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
86 addition
and
44 deletion
+86
-44
idea-plugin/p3c-common/src/main/java/icons/P3cIcons.java
idea-plugin/p3c-common/src/main/java/icons/P3cIcons.java
+11
-6
idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/action/AliInspectionAction.kt
...kotlin/com/alibaba/p3c/idea/action/AliInspectionAction.kt
+2
-1
idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/compatible/inspection/Inspections.kt
...com/alibaba/p3c/idea/compatible/inspection/Inspections.kt
+20
-0
idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/component/AliProjectComponent.kt
...lin/com/alibaba/p3c/idea/component/AliProjectComponent.kt
+6
-2
idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/inspection/AliPmdInspection.kt
...otlin/com/alibaba/p3c/idea/inspection/AliPmdInspection.kt
+3
-2
idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/inspection/RuleInspectionUtils.kt
...in/com/alibaba/p3c/idea/inspection/RuleInspectionUtils.kt
+2
-1
idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/inspection/standalone/MapOrSetKeyShouldOverrideHashCodeEqualsInspection.kt
...lone/MapOrSetKeyShouldOverrideHashCodeEqualsInspection.kt
+2
-2
idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/util/NumberConstants.kt
.../main/kotlin/com/alibaba/p3c/idea/util/NumberConstants.kt
+7
-7
idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/util/ObjectConstants.kt
.../main/kotlin/com/alibaba/p3c/idea/util/ObjectConstants.kt
+9
-9
idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/util/ProblemsUtils.kt
...rc/main/kotlin/com/alibaba/p3c/idea/util/ProblemsUtils.kt
+4
-4
p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/util/NumberConstants.java
...a/com/alibaba/p3c/pmd/lang/java/util/NumberConstants.java
+13
-8
p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/util/StringAndCharConstants.java
...libaba/p3c/pmd/lang/java/util/StringAndCharConstants.java
+7
-2
未找到文件。
idea-plugin/p3c-common/src/main/java/icons/P3cIcons.java
浏览文件 @
6ab9ac35
...
...
@@ -23,11 +23,16 @@ import com.intellij.openapi.util.IconLoader;
* @author caikang
* @date 2016/12/28
*/
public
interface
P3cIcons
{
Icon
ANALYSIS_ACTION
=
IconLoader
.
getIcon
(
"/icons/ali-ide-run.png"
);
public
final
class
P3cIcons
{
private
P3cIcons
()
{
throw
new
AssertionError
(
"icons.P3cIcons"
+
" instances for you!"
);
}
Icon
PROJECT_INSPECTION_ON
=
IconLoader
.
getIcon
(
"/icons/qiyong.png"
);
Icon
PROJECT_INSPECTION_OFF
=
IconLoader
.
getIcon
(
"/icons/tingyong.png"
);
Icon
LANGUAGE
=
IconLoader
.
getIcon
(
"/icons/language.png"
);
Icon
ALIBABA
=
IconLoader
.
getIcon
(
"/icons/alibaba.png"
);
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"
);
}
idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/action/AliInspectionAction.kt
浏览文件 @
6ab9ac35
...
...
@@ -20,6 +20,7 @@ import com.alibaba.p3c.idea.compatible.inspection.Inspections
import
com.alibaba.p3c.idea.ep.InspectionActionExtensionPoint
import
com.alibaba.p3c.idea.i18n.P3cBundle
import
com.alibaba.p3c.idea.inspection.AliBaseInspection
import
com.alibaba.p3c.idea.util.NumberConstants
import
com.beust.jcommander.internal.Lists
import
com.intellij.analysis.AnalysisScope
import
com.intellij.analysis.AnalysisUIOptions
...
...
@@ -68,7 +69,7 @@ class AliInspectionAction : AnAction() {
if
(
psiFile
!=
null
)
{
analysisScope
=
AnalysisScope
(
psiFile
)
projectDir
=
isBaseDir
(
psiFile
.
virtualFile
,
project
)
}
else
if
(
virtualFiles
!=
null
&&
virtualFiles
.
size
>
com
.
alibaba
.
p3c
.
idea
.
NumberConstants
.
INTEGER_SIZE_OR_LENGTH_0
)
{
}
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
)
...
...
idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/compatible/inspection/Inspections.kt
浏览文件 @
6ab9ac35
...
...
@@ -15,9 +15,11 @@
*/
package
com.alibaba.p3c.idea.compatible.inspection
import
com.google.common.base.Splitter
import
com.intellij.codeInspection.ex.InspectionProfileImpl
import
com.intellij.codeInspection.ex.InspectionToolWrapper
import
com.intellij.codeInspection.ex.ScopeToolState
import
com.intellij.codeInspection.javaDoc.JavaDocLocalInspection
import
com.intellij.openapi.project.Project
/**
...
...
@@ -32,6 +34,24 @@ object Inspections {
return
getAllTools
(
project
,
profile
).
filter
(
filter
)
}
fun
addCustomTag
(
project
:
Project
,
tag
:
String
)
{
val
profile
=
InspectionProfileService
.
getProjectInspectionProfile
(
project
)
val
javaDocLocalInspection
=
profile
.
getInspectionTool
(
"JavaDoc"
,
project
)
?.
tool
as
?
JavaDocLocalInspection
?:
return
if
(
javaDocLocalInspection
.
myAdditionalJavadocTags
.
isEmpty
())
{
javaDocLocalInspection
.
myAdditionalJavadocTags
=
tag
return
}
val
tags
=
Splitter
.
on
(
','
).
splitToList
(
javaDocLocalInspection
.
myAdditionalJavadocTags
)
if
(
tags
.
contains
(
tag
))
{
return
}
javaDocLocalInspection
.
myAdditionalJavadocTags
+=
","
+
tag
profile
.
profileChanged
()
profile
.
scopesChanged
()
}
private
fun
getAllTools
(
project
:
Project
,
profile
:
InspectionProfileImpl
):
List
<
InspectionToolWrapper
<
*
,
*
>>
{
val
method
=
InspectionProfileImpl
::
class
.
java
.
methods
.
first
{
it
.
name
==
"getAllTools"
...
...
idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/component/AliProjectComponent.kt
浏览文件 @
6ab9ac35
...
...
@@ -15,6 +15,7 @@
*/
package
com.alibaba.p3c.idea.component
import
com.alibaba.p3c.idea.compatible.inspection.Inspections
import
com.alibaba.p3c.idea.config.P3cConfig
import
com.alibaba.p3c.idea.inspection.AliPmdInspectionInvoker
import
com.alibaba.p3c.idea.pmd.SourceCodeProcessor
...
...
@@ -30,8 +31,10 @@ import com.intellij.psi.PsiManager
* @author caikang
* @date 2016/12/13
*/
class
AliProjectComponent
(
private
val
project
:
Project
,
val
p3cConfig
:
P3cConfig
)
:
AliBaseProjectComponent
{
class
AliProjectComponent
(
private
val
project
:
Project
,
val
p3cConfig
:
P3cConfig
)
:
AliBaseProjectComponent
{
private
val
listener
:
VirtualFileListener
private
val
javaExtension
=
".java"
private
val
velocityExtension
=
".vm"
...
...
@@ -56,6 +59,7 @@ class AliProjectComponent(private val project: Project,
}
override
fun
projectOpened
()
{
Inspections
.
addCustomTag
(
project
,
"date"
)
VirtualFileManager
.
getInstance
().
addVirtualFileListener
(
listener
)
}
...
...
idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/inspection/AliPmdInspection.kt
浏览文件 @
6ab9ac35
...
...
@@ -16,6 +16,7 @@
package
com.alibaba.p3c.idea.inspection
import
com.alibaba.p3c.idea.inspection.AliLocalInspectionToolProvider.ShouldInspectChecker
import
com.alibaba.p3c.idea.util.NumberConstants
import
com.alibaba.p3c.idea.util.QuickFixes
import
com.intellij.codeHighlighting.HighlightDisplayLevel
import
com.intellij.codeInspection.InspectionManager
...
...
@@ -103,8 +104,8 @@ class AliPmdInspection(private val ruleName: String)
var
shortName
=
"Alibaba"
+
ruleName
val
index
=
shortName
.
lastIndexOf
(
"Rule"
)
if
(
index
>
com
.
alibaba
.
p3c
.
idea
.
NumberConstants
.
INDEX_0
)
{
shortName
=
shortName
.
substring
(
com
.
alibaba
.
p3c
.
idea
.
NumberConstants
.
INDEX_0
,
index
)
if
(
index
>
NumberConstants
.
INDEX_0
)
{
shortName
=
shortName
.
substring
(
NumberConstants
.
INDEX_0
,
index
)
}
return
shortName
}
...
...
idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/inspection/RuleInspectionUtils.kt
浏览文件 @
6ab9ac35
...
...
@@ -17,6 +17,7 @@ package com.alibaba.p3c.idea.inspection
import
com.alibaba.p3c.idea.config.P3cConfig
import
com.alibaba.p3c.idea.util.HighlightDisplayLevels
import
com.alibaba.p3c.idea.util.NumberConstants
import
com.alibaba.p3c.pmd.I18nResources
import
com.alibaba.smartfox.idea.common.util.getService
import
com.google.common.base.Joiner
...
...
@@ -177,7 +178,7 @@ object RuleInspectionUtils {
logger
.
info
(
"start to find rule sets from jar "
+
url
)
var
path
=
URLDecoder
.
decode
(
url
.
path
,
StandardCharsets
.
UTF_8
.
name
())
val
index
=
path
.
lastIndexOf
(
URLUtil
.
JAR_SEPARATOR
)
if
(
index
>
com
.
alibaba
.
p3c
.
idea
.
NumberConstants
.
INDEX_0
)
{
if
(
index
>
NumberConstants
.
INDEX_0
)
{
path
=
path
.
substring
(
"file:"
.
length
,
index
)
}
val
jarFile
=
JarFile
(
path
)
...
...
idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/inspection/standalone/MapOrSetKeyShouldOverrideHashCodeEqualsInspection.kt
浏览文件 @
6ab9ac35
...
...
@@ -15,8 +15,8 @@
*/
package
com.alibaba.p3c.idea.inspection.standalone
import
com.alibaba.p3c.idea.NumberConstants
import
com.alibaba.p3c.idea.ObjectConstants
import
com.alibaba.p3c.idea.
util.
NumberConstants
import
com.alibaba.p3c.idea.
util.
ObjectConstants
import
com.alibaba.p3c.idea.i18n.P3cBundle
import
com.alibaba.p3c.idea.inspection.AliBaseInspection
import
com.alibaba.p3c.idea.util.HighlightDisplayLevels
...
...
idea-plugin/p3c-common/src/main/
java/com/alibaba/p3c/idea/NumberConstants.java
→
idea-plugin/p3c-common/src/main/
kotlin/com/alibaba/p3c/idea/util/NumberConstants.kt
浏览文件 @
6ab9ac35
...
...
@@ -13,17 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com.alibaba.p3c.idea
;
package
com.alibaba.p3c.idea
.util
/**
* @author caikang
* @date 2016/12/28
*/
public
interface
NumberConstants
{
int
INTEGER_SIZE_OR_LENGTH_0
=
0
;
int
INTEGER_SIZE_OR_LENGTH_1
=
1
;
int
INTEGER_SIZE_OR_LENGTH_2
=
2
;
object
NumberConstants
{
val
INTEGER_SIZE_OR_LENGTH_0
=
0
val
INTEGER_SIZE_OR_LENGTH_1
=
1
val
INTEGER_SIZE_OR_LENGTH_2
=
2
int
INDEX_0
=
0
;
int
INDEX_1
=
1
;
val
INDEX_0
=
0
val
INDEX_1
=
1
}
idea-plugin/p3c-common/src/main/
java/com/alibaba/p3c/idea/ObjectConstants.java
→
idea-plugin/p3c-common/src/main/
kotlin/com/alibaba/p3c/idea/util/ObjectConstants.kt
浏览文件 @
6ab9ac35
...
...
@@ -13,18 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com.alibaba.p3c.idea
;
package
com.alibaba.p3c.idea
.util
/**
* @author caikang
* @date 2016/12/28
*/
public
interface
ObjectConstants
{
String
METHOD_NAME_EQUALS
=
"equals"
;
String
METHOD_NAME_HASHCODE
=
"hashCode"
;
String
METHOD_NAME_ADD
=
"add"
;
String
METHOD_NAME_PUT
=
"put"
;
String
CLASS_LITERAL
=
"class"
;
String
INTERFACE_LITERAL
=
"interface"
;
String
ENUM_LITERAL
=
"enum"
;
object
ObjectConstants
{
val
METHOD_NAME_EQUALS
=
"equals"
val
METHOD_NAME_HASHCODE
=
"hashCode"
val
METHOD_NAME_ADD
=
"add"
val
METHOD_NAME_PUT
=
"put"
val
CLASS_LITERAL
=
"class"
val
INTERFACE_LITERAL
=
"interface"
val
ENUM_LITERAL
=
"enum"
}
idea-plugin/p3c-common/src/main/kotlin/com/alibaba/p3c/idea/util/ProblemsUtils.kt
浏览文件 @
6ab9ac35
...
...
@@ -111,9 +111,9 @@ object ProblemsUtils {
if
(
psiElement
==
null
)
{
return
null
}
if
(
psiElement
is
PsiKeyword
&&
psiElement
.
text
!=
null
&&
(
com
.
alibaba
.
p3c
.
idea
.
ObjectConstants
.
CLASS_LITERAL
==
psiElement
.
text
||
com
.
alibaba
.
p3c
.
idea
.
ObjectConstants
.
INTERFACE_LITERAL
==
psiElement
.
text
||
com
.
alibaba
.
p3c
.
idea
.
ObjectConstants
.
ENUM_LITERAL
==
psiElement
.
text
)
&&
psiElement
.
parent
is
PsiClass
)
{
if
(
psiElement
is
PsiKeyword
&&
psiElement
.
text
!=
null
&&
(
ObjectConstants
.
CLASS_LITERAL
==
psiElement
.
text
||
ObjectConstants
.
INTERFACE_LITERAL
==
psiElement
.
text
||
ObjectConstants
.
ENUM_LITERAL
==
psiElement
.
text
)
&&
psiElement
.
parent
is
PsiClass
)
{
val
parent
=
psiElement
.
parent
as
PsiClass
val
identifier
=
parent
.
nameIdentifier
return
identifier
?:
psiElement
...
...
@@ -131,4 +131,4 @@ object ProblemsUtils {
desc
,
ProblemHighlightType
.
GENERIC_ERROR_OR_WARNING
,
isOnTheFly
,
quickFix
())
}
}
\ No newline at end of file
}
p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/util/NumberConstants.java
浏览文件 @
6ab9ac35
...
...
@@ -19,13 +19,18 @@ package com.alibaba.p3c.pmd.lang.java.util;
* @author caikang
* @date 2016/12/28
*/
public
interface
NumberConstants
{
int
INTEGER_SIZE_OR_LENGTH_0
=
0
;
int
INTEGER_SIZE_OR_LENGTH_1
=
1
;
int
INTEGER_SIZE_OR_LENGTH_2
=
2
;
int
INTEGER_SIZE_OR_LENGTH_3
=
3
;
public
final
class
NumberConstants
{
private
NumberConstants
()
{
throw
new
AssertionError
(
"com.alibaba.p3c.pmd.lang.java.util.NumberConstants"
+
" instances for you!"
)
;
}
int
INDEX_0
=
0
;
int
INDEX_1
=
1
;
int
INDEX_2
=
2
;
public
static
final
int
INTEGER_SIZE_OR_LENGTH_0
=
0
;
public
static
final
int
INTEGER_SIZE_OR_LENGTH_1
=
1
;
public
static
final
int
INTEGER_SIZE_OR_LENGTH_2
=
2
;
public
static
final
int
INTEGER_SIZE_OR_LENGTH_3
=
3
;
public
static
final
int
INDEX_0
=
0
;
public
static
final
int
INDEX_1
=
1
;
public
static
final
int
INDEX_2
=
2
;
}
p3c-pmd/src/main/java/com/alibaba/p3c/pmd/lang/java/util/StringAndCharConstants.java
浏览文件 @
6ab9ac35
...
...
@@ -19,6 +19,11 @@ package com.alibaba.p3c.pmd.lang.java.util;
* @author caikang
* @date 2017/03/28
*/
public
interface
StringAndCharConstants
{
char
DOT
=
'.'
;
public
final
class
StringAndCharConstants
{
private
StringAndCharConstants
(){
throw
new
AssertionError
(
"com.alibaba.p3c.pmd.lang.java.util.StringAndCharConstants"
+
" instances for you!"
);
}
public
static
final
char
DOT
=
'.'
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录