Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
c3c4ae5f
Kaydet (Commit)
c3c4ae5f
authored
Eyl 15, 2016
tarafından
Noel Grandin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
use split() to simplify loplugin python code
Change-Id: Ib6d7acf54ca6c12a3b096435f8a621244df88b4f
üst
6df2c90c
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
60 additions
and
84 deletions
+60
-84
countusersofdefaultparams.py
compilerplugins/clang/countusersofdefaultparams.py
+3
-4
mergeclasses.py
compilerplugins/clang/mergeclasses.py
+10
-14
singlevalfields.py
compilerplugins/clang/singlevalfields.py
+9
-14
unnecessaryvirtual.py
compilerplugins/clang/unnecessaryvirtual.py
+5
-8
unuseddefaultparams.py
compilerplugins/clang/unuseddefaultparams.py
+9
-12
unusedfields.py
compilerplugins/clang/unusedfields.py
+9
-12
unusedmethods.py
compilerplugins/clang/unusedmethods.py
+15
-20
No files found.
compilerplugins/clang/countusersofdefaultparams.py
Dosyayı görüntüle @
c3c4ae5f
...
...
@@ -17,8 +17,8 @@ def normalizeTypeParams( line ):
# I have not yet found a way of suppressing the gbuild output.
with
io
.
open
(
"loplugin.countusersofdefaultparams.log"
,
"rb"
,
buffering
=
1024
*
1024
)
as
txt
:
for
line
in
txt
:
if
line
.
startswith
(
"defn:
\t
"
):
tokens
=
line
.
strip
()
.
split
(
"
\t
"
)
tokens
=
line
.
strip
()
.
split
(
"
\t
"
)
if
tokens
[
0
]
==
"defn:"
:
access
=
tokens
[
1
]
returnType
=
tokens
[
2
]
nameAndParams
=
tokens
[
3
]
...
...
@@ -27,8 +27,7 @@ with io.open("loplugin.countusersofdefaultparams.log", "rb", buffering=1024*1024
definitionToSourceLocationMap
[
funcInfo
]
=
sourceLocation
if
not
funcInfo
in
callDict
:
callDict
[
funcInfo
]
=
set
()
elif
line
.
startswith
(
"call:
\t
"
):
tokens
=
line
.
strip
()
.
split
(
"
\t
"
)
elif
tokens
[
0
]
==
"call:"
:
returnType
=
tokens
[
1
]
nameAndParams
=
tokens
[
2
]
sourceLocationOfCall
=
tokens
[
3
]
...
...
compilerplugins/clang/mergeclasses.py
Dosyayı görüntüle @
c3c4ae5f
...
...
@@ -9,10 +9,10 @@ definitionToFileDict = {}
with
open
(
"loplugin.mergeclasses.log"
)
as
txt
:
for
line
in
txt
:
tokens
=
line
.
strip
()
.
split
(
"
\t
"
)
if
line
.
startswith
(
"instantiated:
\t
"
):
idx1
=
line
.
find
(
"
\t
"
)
clazzName
=
line
[
idx1
+
1
:
len
(
line
)
-
1
]
if
tokens
[
0
]
==
"instantiated:"
:
clazzName
=
tokens
[
1
]
if
(
clazzName
.
startswith
(
"const "
)):
clazzName
=
clazzName
[
6
:]
if
(
clazzName
.
startswith
(
"class "
)):
...
...
@@ -21,20 +21,16 @@ with open("loplugin.mergeclasses.log") as txt:
clazzName
=
clazzName
[:
len
(
clazzName
)
-
3
]
instantiatedSet
.
add
(
clazzName
)
elif
line
.
startswith
(
"definition:
\t
"
):
idx1
=
line
.
find
(
"
\t
"
)
idx2
=
line
.
find
(
"
\t
"
,
idx1
+
1
)
clazzName
=
line
[
idx1
+
1
:
idx2
]
# the +2 is so we skip the leading /
fileName
=
line
[
idx2
+
2
:
len
(
line
)
-
1
]
elif
tokens
[
0
]
==
"definition:"
:
clazzName
=
tokens
[
1
]
# the 1.. is so we skip the leading /
fileName
=
tokens
[
1
][
1.
.
]
definitionSet
.
add
(
clazzName
)
definitionToFileDict
[
clazzName
]
=
fileName
elif
line
.
startswith
(
"has-subclass:
\t
"
):
idx1
=
line
.
find
(
"
\t
"
)
idx2
=
line
.
find
(
"
\t
"
,
idx1
+
1
)
child
=
line
[
idx1
+
1
:
idx2
]
parent
=
line
[
idx2
+
1
:
len
(
line
)
-
1
]
elif
tokens
[
0
]
==
"has-subclass:"
:
child
=
tokens
[
1
]
parent
=
tokens
[
2
]
if
(
parent
.
startswith
(
"class "
)):
parent
=
parent
[
6
:]
elif
(
parent
.
startswith
(
"struct "
)):
...
...
compilerplugins/clang/singlevalfields.py
Dosyayı görüntüle @
c3c4ae5f
...
...
@@ -16,22 +16,17 @@ def normalizeTypeParams( line ):
# reading as binary (since we known it is pure ascii) is much faster than reading as unicode
with
io
.
open
(
"loplugin.singlevalfields.log"
,
"rb"
,
buffering
=
1024
*
1024
)
as
txt
:
for
line
in
txt
:
if
line
.
startswith
(
"defn:
\t
"
):
idx1
=
line
.
find
(
"
\t
"
)
idx2
=
line
.
find
(
"
\t
"
,
idx1
+
1
)
idx3
=
line
.
find
(
"
\t
"
,
idx2
+
1
)
parentClass
=
normalizeTypeParams
(
line
[
idx1
+
1
:
idx2
])
fieldName
=
normalizeTypeParams
(
line
[
idx2
+
1
:
idx3
])
sourceLocation
=
line
[
idx3
+
1
:]
.
strip
()
tokens
=
line
.
strip
()
.
split
(
"
\t
"
)
if
tokens
[
0
]
==
"defn:"
:
parentClass
=
normalizeTypeParams
(
tokens
[
1
])
fieldName
=
normalizeTypeParams
(
tokens
[
2
])
sourceLocation
=
tokens
[
3
]
fieldInfo
=
(
parentClass
,
fieldName
)
definitionToSourceLocationMap
[
fieldInfo
]
=
sourceLocation
elif
line
.
startswith
(
"asgn:
\t
"
):
idx1
=
line
.
find
(
"
\t
"
)
idx2
=
line
.
find
(
"
\t
"
,
idx1
+
1
)
idx3
=
line
.
find
(
"
\t
"
,
idx2
+
1
)
parentClass
=
normalizeTypeParams
(
line
[
idx1
+
1
:
idx2
])
fieldName
=
normalizeTypeParams
(
line
[
idx2
+
1
:
idx3
])
assignValue
=
line
[
idx3
+
1
:]
.
strip
()
elif
tokens
[
0
]
==
"asgn:"
:
parentClass
=
normalizeTypeParams
(
tokens
[
1
])
fieldName
=
normalizeTypeParams
(
tokens
[
2
])
assignValue
=
tokens
[
3
]
fieldInfo
=
(
parentClass
,
fieldName
)
if
not
fieldInfo
in
fieldAssignDict
:
fieldAssignDict
[
fieldInfo
]
=
set
()
...
...
compilerplugins/clang/unnecessaryvirtual.py
Dosyayı görüntüle @
c3c4ae5f
...
...
@@ -9,15 +9,12 @@ overridingSet = set()
with
io
.
open
(
"loplugin.unnecessaryvirtual.log"
,
"rb"
,
buffering
=
1024
*
1024
)
as
txt
:
for
line
in
txt
:
if
line
.
startswith
(
"definition:
\t
"
):
idx1
=
line
.
find
(
"
\t
"
)
clazzName
=
line
[
idx1
+
1
:
len
(
line
)
-
1
]
tokens
=
line
.
strip
()
.
split
(
"
\t
"
)
if
tokens
[
0
]
==
"definition:"
:
clazzName
=
tokens
[
1
]
definitionSet
.
add
(
clazzName
)
elif
line
.
startswith
(
"overriding:
\t
"
):
idx1
=
line
.
find
(
"
\t
"
)
clazzName
=
line
[
idx1
+
1
:
len
(
line
)
-
1
]
elif
tokens
[
0
]
==
"overriding:"
:
clazzName
=
tokens
[
1
]
overridingSet
.
add
(
clazzName
)
with
open
(
"loplugin.unnecessaryvirtual.report"
,
"wt"
)
as
f
:
...
...
compilerplugins/clang/unuseddefaultparams.py
Dosyayı görüntüle @
c3c4ae5f
...
...
@@ -18,21 +18,18 @@ def normalizeTypeParams( line ):
# I have not yet found a way of suppressing the gbuild output.
with
io
.
open
(
"loplugin.unuseddefaultparams.log"
,
"rb"
,
buffering
=
1024
*
1024
)
as
txt
:
for
line
in
txt
:
if
line
.
startswith
(
"defn:
\t
"
):
idx1
=
line
.
find
(
"
\t
"
,
6
)
idx2
=
line
.
find
(
"
\t
"
,
idx1
+
1
)
idx3
=
line
.
find
(
"
\t
"
,
idx2
+
1
)
access
=
line
[
6
:
idx1
]
returnType
=
line
[
idx1
+
1
:
idx2
]
nameAndParams
=
line
[
idx2
+
1
:
idx3
]
sourceLocation
=
line
[
idx3
+
1
:]
.
strip
()
tokens
=
line
.
strip
()
.
split
(
"
\t
"
)
if
tokens
[
0
]
==
"defn:"
:
access
=
tokens
[
1
]
returnType
=
tokens
[
2
]
nameAndParams
=
tokens
[
3
]
sourceLocation
=
tokens
[
4
]
funcInfo
=
(
normalizeTypeParams
(
returnType
),
normalizeTypeParams
(
nameAndParams
))
definitionSet
.
add
(
funcInfo
)
definitionToSourceLocationMap
[
funcInfo
]
=
sourceLocation
elif
line
.
startswith
(
"call:
\t
"
):
idx1
=
line
.
find
(
"
\t
"
,
6
)
returnType
=
line
[
6
:
idx1
]
nameAndParams
=
line
[
idx1
+
1
:]
.
strip
()
elif
tokens
[
0
]
==
"call:"
:
returnType
=
tokens
[
1
]
nameAndParams
=
tokens
[
2
]
callSet
.
add
((
normalizeTypeParams
(
returnType
),
normalizeTypeParams
(
nameAndParams
)))
# Invert the definitionToSourceLocationMap.
...
...
compilerplugins/clang/unusedfields.py
Dosyayı görüntüle @
c3c4ae5f
...
...
@@ -25,21 +25,18 @@ def normalizeTypeParams( line ):
# I have not yet found a way of suppressing the gbuild output.
with
io
.
open
(
"loplugin.unusedfields.log"
,
"rb"
,
buffering
=
1024
*
1024
)
as
txt
:
for
line
in
txt
:
if
line
.
startswith
(
"definition:
\t
"
):
idx1
=
line
.
find
(
"
\t
"
,
12
)
idx2
=
line
.
find
(
"
\t
"
,
idx1
+
1
)
idx3
=
line
.
find
(
"
\t
"
,
idx2
+
1
)
funcInfo
=
(
normalizeTypeParams
(
line
[
12
:
idx1
]),
line
[
idx1
+
1
:
idx2
])
tokens
=
line
.
strip
()
.
split
(
"
\t
"
)
if
tokens
[
0
]
==
"definition:"
:
funcInfo
=
(
normalizeTypeParams
(
tokens
[
1
]),
tokens
[
2
])
definitionSet
.
add
(
funcInfo
)
definitionToTypeMap
[
funcInfo
]
=
line
[
idx2
+
1
:
idx3
]
.
strip
()
definitionToSourceLocationMap
[
funcInfo
]
=
line
[
idx3
+
1
:]
.
strip
()
elif
line
.
startswith
(
"touch:
\t
"
):
idx1
=
line
.
find
(
"
\t
"
,
7
)
callInfo
=
(
normalizeTypeParams
(
line
[
7
:
idx1
]),
line
[
idx1
+
1
:]
.
strip
())
definitionToTypeMap
[
funcInfo
]
=
tokens
[
3
]
definitionToSourceLocationMap
[
funcInfo
]
=
tokens
[
4
]
elif
tokens
[
0
]
==
"touch:"
:
callInfo
=
(
normalizeTypeParams
(
tokens
[
1
]),
tokens
[
2
])
callSet
.
add
(
callInfo
)
elif
line
.
startswith
(
"read:
\t
"
)
:
elif
tokens
[
0
]
==
"read:"
:
idx1
=
line
.
find
(
"
\t
"
,
6
)
readInfo
=
(
normalizeTypeParams
(
line
[
6
:
idx1
]),
line
[
idx1
+
1
:]
.
strip
()
)
readInfo
=
(
normalizeTypeParams
(
tokens
[
1
]),
tokens
[
2
]
)
readFromSet
.
add
(
readInfo
)
# Invert the definitionToSourceLocationMap
...
...
compilerplugins/clang/unusedmethods.py
Dosyayı görüntüle @
c3c4ae5f
...
...
@@ -135,33 +135,28 @@ def normalizeTypeParams( line ):
# I have not yet found a way of suppressing the gbuild output.
with
io
.
open
(
"loplugin.unusedmethods.log"
,
"rb"
,
buffering
=
1024
*
1024
)
as
txt
:
for
line
in
txt
:
if
line
.
startswith
(
"definition:
\t
"
):
idx1
=
line
.
find
(
"
\t
"
,
12
)
idx2
=
line
.
find
(
"
\t
"
,
idx1
+
1
)
idx3
=
line
.
find
(
"
\t
"
,
idx2
+
1
)
access
=
line
[
12
:
idx1
]
returnType
=
line
[
idx1
+
1
:
idx2
]
nameAndParams
=
line
[
idx2
+
1
:
idx3
]
sourceLocation
=
line
[
idx3
+
1
:]
.
strip
()
tokens
=
line
.
strip
()
.
split
(
"
\t
"
)
if
tokens
[
0
]
==
"definition:"
:
access
=
tokens
[
1
]
returnType
=
tokens
[
2
]
nameAndParams
=
tokens
[
3
]
sourceLocation
=
tokens
[
4
]
funcInfo
=
(
normalizeTypeParams
(
returnType
),
normalizeTypeParams
(
nameAndParams
))
definitionSet
.
add
(
funcInfo
)
if
access
==
"public"
:
publicDefinitionSet
.
add
(
funcInfo
)
definitionToSourceLocationMap
[
funcInfo
]
=
sourceLocation
elif
line
.
startswith
(
"call:
\t
"
):
idx1
=
line
.
find
(
"
\t
"
,
6
)
returnType
=
line
[
6
:
idx1
]
nameAndParams
=
line
[
idx1
+
1
:]
.
strip
()
elif
tokens
[
0
]
==
"call:"
:
returnType
=
tokens
[
1
]
nameAndParams
=
tokens
[
2
]
callSet
.
add
((
normalizeTypeParams
(
returnType
),
normalizeTypeParams
(
nameAndParams
)))
elif
line
.
startswith
(
"usedReturn:
\t
"
):
idx1
=
line
.
find
(
"
\t
"
,
12
)
returnType
=
line
[
12
:
idx1
]
nameAndParams
=
line
[
idx1
+
1
:]
.
strip
()
elif
tokens
[
0
]
==
"usedReturn:"
:
returnType
=
tokens
[
1
]
nameAndParams
=
tokens
[
2
]
usedReturnSet
.
add
((
normalizeTypeParams
(
returnType
),
normalizeTypeParams
(
nameAndParams
)))
elif
line
.
startswith
(
"calledFromOutsideSet:
\t
"
):
idx1
=
line
.
find
(
"
\t
"
,
22
)
returnType
=
line
[
22
:
idx1
]
nameAndParams
=
line
[
idx1
+
1
:]
.
strip
()
elif
tokens
[
0
]
==
"calledFromOutsideSet:"
:
returnType
=
tokens
[
1
]
nameAndParams
=
tokens
[
2
]
calledFromOutsideSet
.
add
((
normalizeTypeParams
(
returnType
),
normalizeTypeParams
(
nameAndParams
)))
# Invert the definitionToSourceLocationMap.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment