Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eclipse Projects
Eclipse Titan
titan.EclipsePlug-ins
Commits
7e15c5b0
Commit
7e15c5b0
authored
Apr 25, 2016
by
ekrisza
Browse files
style improvements
parent
3e02f423
Changes
20
Hide whitespace changes
Inline
Side-by-side
org.eclipse.titanium/src/org/eclipse/titanium/gui/FindWindow.java
View file @
7e15c5b0
...
...
@@ -177,10 +177,10 @@ public class FindWindow<T extends Comparable> extends Dialog {
noResult
=
false
;
}
if
(!
noResult
)
{
showResultTable
(
true
);
}
else
{
if
(
noResult
)
{
errorHandler
.
reportInformation
(
"The search hasn't found such node!"
);
}
else
{
showResultTable
(
true
);
}
}
});
...
...
org.eclipse.titanium/src/org/eclipse/titanium/markers/export/XlsProblemExporter.java
View file @
7e15c5b0
...
...
@@ -166,7 +166,7 @@ public class XlsProblemExporter extends BaseProblemExporter {
Row
row2
=
summarySheet
.
createRow
(
2
);
row2
.
createCell
(
0
).
setCellValue
(
"Commulative Project Risk Factor"
);
int
riskFactor
=
(
new
RiskFactorCalculator
()
)
.
measure
(
project
,
smellCount
);
int
riskFactor
=
new
RiskFactorCalculator
().
measure
(
project
,
smellCount
);
row2
.
createCell
(
1
).
setCellValue
(
riskFactor
);
summarySheet
.
autoSizeColumn
(
0
);
...
...
org.eclipse.titanium/src/org/eclipse/titanium/markers/handler/Marker.java
View file @
7e15c5b0
...
...
@@ -10,7 +10,6 @@ package org.eclipse.titanium.markers.handler;
import
org.eclipse.core.resources.IMarker
;
import
org.eclipse.core.resources.IResource
;
import
org.eclipse.titan.designer.AST.Location
;
import
org.eclipse.titan.designer.AST.NULL_Location
;
import
org.eclipse.titanium.markers.types.CodeSmellType
;
/**
...
...
org.eclipse.titanium/src/org/eclipse/titanium/markers/spotters/BaseCodeSmellSpotter.java
View file @
7e15c5b0
...
...
@@ -57,7 +57,9 @@ abstract class BaseCodeSmellSpotter {
final
IPreferencesService
prefs
=
Platform
.
getPreferencesService
();
final
ProblemTypePreference
pref
=
CodeSmellTypeToPreferenceTypeMapper
.
getPreferenceType
(
type
);
if
(
prefs
!=
null
)
{
if
(
prefs
==
null
)
{
severity
=
IMarker
.
SEVERITY_WARNING
;
}
else
{
final
String
prefName
=
pref
.
getPreferenceName
();
final
String
warnLevel
=
prefs
.
getString
(
Activator
.
PLUGIN_ID
,
prefName
,
GeneralConstants
.
IGNORE
,
null
);
// Validating and parsing warnLevel
...
...
@@ -70,8 +72,6 @@ abstract class BaseCodeSmellSpotter {
}
else
{
throw
new
IllegalStateException
(
"warnLevel should be one of IGNORE, WARNING or ERROR, not "
+
warnLevel
);
}
}
else
{
severity
=
IMarker
.
SEVERITY_WARNING
;
}
}
...
...
org.eclipse.titanium/src/org/eclipse/titanium/markers/spotters/implementation/AltstepCoverage.java
View file @
7e15c5b0
...
...
@@ -259,7 +259,7 @@ public class AltstepCoverage {
while
(
typeIt
.
hasNext
())
{
sb
.
append
(
", "
).
append
(
typeIt
.
next
());
}
sb
.
append
(
"
\n
"
);
sb
.
append
(
'
\n
'
);
}
problems
.
report
(
reportAt
,
sb
.
toString
());
}
...
...
org.eclipse.titanium/src/org/eclipse/titanium/markers/spotters/implementation/Lazy.java
View file @
7e15c5b0
...
...
@@ -11,6 +11,7 @@ import java.text.MessageFormat;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
org.eclipse.titan.designer.AST.ASTVisitor
;
import
org.eclipse.titan.designer.AST.Assignment
;
...
...
@@ -71,7 +72,7 @@ public class Lazy extends BaseModuleCodeSmellSpotter {
node
.
accept
(
relevantNodeBuilder
);
// Evaluate tree and return with FormalParameters which have to be evaluated.
Hash
Set
<
FormalParameter
>
shouldBeEvaluated
=
relevantNodeBuilder
.
collectRelevantReferences
();
Set
<
FormalParameter
>
shouldBeEvaluated
=
relevantNodeBuilder
.
collectRelevantReferences
();
for
(
FormalParameter
formalParameter
:
formalParameterCollector
.
getItems
())
{
boolean
isLazy
=
formalParameter
.
getIsLazy
();
...
...
@@ -119,7 +120,7 @@ public class Lazy extends BaseModuleCodeSmellSpotter {
private
List
<
RelevantNodeBuilder
>
nodes
;
// Contains possible FormalParameters of expression block of If_Statement and SelectCase_Statement.
private
Hash
Set
<
FormalParameter
>
strictFormalParameters
;
private
Set
<
FormalParameter
>
strictFormalParameters
;
// Contains possible FormalParameters of StatementBloc and Statement and AltGuard.
private
HashSet
<
FormalParameter
>
referencedFormalParameters
;
...
...
@@ -176,7 +177,7 @@ public class Lazy extends BaseModuleCodeSmellSpotter {
return
V_CONTINUE
;
}
public
Hash
Set
<
FormalParameter
>
collectRelevantReferences
()
{
public
Set
<
FormalParameter
>
collectRelevantReferences
()
{
HashSet
<
FormalParameter
>
shouldBeEvaluated
=
new
HashSet
<
FormalParameter
>();
// After that we disregard content's of nodes
...
...
@@ -189,14 +190,14 @@ public class Lazy extends BaseModuleCodeSmellSpotter {
return
referencedFormalParameters
;
}
else
{
Hash
Set
<
FormalParameter
>
tempStricts
=
new
HashSet
<
FormalParameter
>();
Set
<
FormalParameter
>
tempStricts
=
new
HashSet
<
FormalParameter
>();
for
(
int
index
=
0
,
nodeSize
=
nodes
.
size
();
index
<
nodeSize
;
++
index
)
{
if
(
haveToContinue
)
{
tempStricts
.
addAll
(
nodes
.
get
(
index
).
strictFormalParameters
);
Hash
Set
<
FormalParameter
>
temp
=
nodes
.
get
(
index
).
collectRelevantReferences
();
Set
<
FormalParameter
>
temp
=
nodes
.
get
(
index
).
collectRelevantReferences
();
if
(
root
instanceof
StatementBlock
||
root
instanceof
Definition
||
root
instanceof
AltGuard
)
{
shouldBeEvaluated
.
addAll
(
temp
);
...
...
org.eclipse.titanium/src/org/eclipse/titanium/metrics/Statistics.java
View file @
7e15c5b0
...
...
@@ -47,7 +47,9 @@ public class Statistics {
public
Statistics
(
final
double
[]
nums
,
final
IMetricEnum
metric
,
final
IRisk
risk
)
{
final
int
n
=
nums
.
length
;
double
total
=
0
;
double
max
,
dev
,
mean
;
double
max
;
double
dev
;
double
mean
;
final
Set
<
StatColumn
>
stats
=
metric
.
requestedStatistics
();
final
boolean
isInt
=
metric
.
isInteger
();
...
...
org.eclipse.titanium/src/org/eclipse/titanium/metrics/risk/LinearRisk.java
View file @
7e15c5b0
...
...
@@ -17,7 +17,8 @@ public class LinearRisk extends BaseRisk {
@Override
public
double
getRiskValue
(
final
Number
value
)
{
double
risk
=
0
;
double
l1
,
l2
;
double
l1
;
double
l2
;
final
double
val
=
value
==
null
?
0.0
:
value
.
doubleValue
();
switch
(
method
)
{
case
NEVER:
...
...
org.eclipse.titanium/src/org/eclipse/titanium/metrics/risk/TriangleRisk.java
View file @
7e15c5b0
...
...
@@ -17,7 +17,8 @@ public class TriangleRisk extends BaseRisk {
@Override
public
double
getRiskValue
(
final
Number
value
)
{
double
risk
=
0
;
double
l1
,
l2
;
double
l1
;
double
l2
;
final
double
dist
=
0.5
-
Math
.
abs
(
value
.
doubleValue
()
-
0.5
);
switch
(
method
)
{
case
NEVER:
...
...
org.eclipse.titanium/src/org/eclipse/titanium/metrics/topview/Comparator.java
View file @
7e15c5b0
...
...
@@ -38,12 +38,14 @@ class Comparator extends ViewerComparator {
final
Module
m1
=
(
Module
)
e1
;
final
Module
m2
=
(
Module
)
e2
;
double
risk1
=
0
,
risk2
=
0
;
double
risk1
=
0
;
double
risk2
=
0
;
for
(
IMetricEnum
m
:
metrics
)
{
risk1
+=
mw
.
getRiskValue
(
m
,
m1
.
getName
());
risk2
+=
mw
.
getRiskValue
(
m
,
m2
.
getName
());
}
double
r
=
risk2
-
risk1
;
final
double
r
=
risk2
-
risk1
;
if
(
r
<
0.0001
)
{
return
-
1
;
}
else
if
(
r
>
0.0001
)
{
...
...
org.eclipse.titanium/src/org/eclipse/titanium/metrics/view/XLSExporter.java
View file @
7e15c5b0
...
...
@@ -37,7 +37,7 @@ import org.apache.poi.ss.usermodel.Sheet;
*/
class
XLSExporter
{
private
File
file
;
private
MetricData
data
;
private
final
MetricData
data
;
public
XLSExporter
(
final
MetricData
data
)
{
this
.
data
=
data
;
...
...
@@ -119,7 +119,7 @@ class XLSExporter {
}
class
CNComparator
implements
Comparator
<
IContentNode
>
{
private
MetricData
data
;
private
final
MetricData
data
;
public
CNComparator
(
final
MetricData
data
)
{
this
.
data
=
data
;
...
...
org.eclipse.titanium/src/org/eclipse/titanium/organize/OrganizeImports.java
View file @
7e15c5b0
...
...
@@ -208,15 +208,15 @@ public final class OrganizeImports {
final
Module
addMod
=
parser
.
getModuleByName
(
parser
.
containedModule
(
file
));
final
String
importName
=
addMod
.
getIdentifier
().
getTtcnName
();
if
(!
importNamesAdded
.
contains
(
importName
))
{
StringBuilder
impText
=
new
StringBuilder
(
"import from "
+
importName
+
" all;"
);
StringBuilder
impText
=
new
StringBuilder
(
"import from "
).
append
(
importName
).
append
(
" all;"
);
if
(
importChangeMethod
.
equals
(
OrganizeImportPreferencePage
.
COMMENT_THEM
))
{
impText
.
append
(
" // Added automatically to resolve "
+
ref
.
getDisplayName
());
impText
.
append
(
" // Added automatically to resolve "
).
append
(
ref
.
getDisplayName
());
}
newImports
.
add
(
new
ImportText
(
importName
,
impText
.
toString
()
+
NEWLINE
));
importNamesAdded
.
add
(
importName
);
if
(
reportDebug
)
{
StringBuilder
sb
=
new
StringBuilder
(
"For "
+
ref
.
getDisplayName
()
+
": "
);
StringBuilder
sb
=
new
StringBuilder
(
"For "
).
append
(
ref
.
getDisplayName
()
).
append
(
": "
);
sb
.
append
(
impText
.
toString
());
TITANDebugConsole
.
println
(
sb
.
toString
());
}
...
...
@@ -362,11 +362,7 @@ class ImportText implements Comparable<ImportText> {
return
false
;
}
if
(
moduleName
.
equals
(((
ImportText
)
obj
).
moduleName
))
{
return
true
;
}
return
false
;
return
moduleName
.
equals
(((
ImportText
)
obj
).
moduleName
);
}
@Override
...
...
org.eclipse.titanium/src/org/eclipse/titanium/preferences/PreferenceConstants.java
View file @
7e15c5b0
...
...
@@ -49,6 +49,8 @@ public final class PreferenceConstants {
public
static
final
String
CLUSTER_AUTO_FOLDER
=
"Auto_folder"
;
public
static
final
String
CLUSTER_AUTO_REGEXP
=
"Auto_regexp"
;
public
static
final
String
CLUSTER_AUTO_NAME
=
"Auto_name"
;
public
static
final
String
BASE_RISK_FACTOR
=
"BASE_RISK_FACTOR"
;
/** private constructor to disable instantiation */
private
PreferenceConstants
()
{
...
...
@@ -70,6 +72,4 @@ public final class PreferenceConstants {
public
static
String
nameMetricGraph
(
final
String
id
)
{
return
METRIC_GRAPH
+
id
;
}
public
static
final
String
BASE_RISK_FACTOR
=
"BASE_RISK_FACTOR"
;
}
org.eclipse.titanium/src/org/eclipse/titanium/preferences/pages/MetricsLimitPreferencePage.java
View file @
7e15c5b0
...
...
@@ -49,7 +49,7 @@ public class MetricsLimitPreferencePage extends PreferencePage implements IWorkb
GridLayout
l
=
new
GridLayout
();
l
.
numColumns
=
2
;
page
.
setLayout
(
l
);
for
(
org
.
eclipse
.
titanium
.
metrics
.
MetricGroup
type
:
MetricGroup
.
values
())
{
for
(
MetricGroup
type
:
MetricGroup
.
values
())
{
Label
header
=
new
Label
(
page
,
0
);
header
.
setText
(
type
.
getGroupName
()
+
" metrics"
);
GridData
headerData
=
new
GridData
();
...
...
org.eclipse.titanium/src/org/eclipse/titanium/preferences/pages/MetricsViewPreferencePage.java
View file @
7e15c5b0
...
...
@@ -46,7 +46,7 @@ public class MetricsViewPreferencePage extends PreferencePage implements IWorkbe
GridLayout
l
=
new
GridLayout
();
l
.
numColumns
=
2
;
page
.
setLayout
(
l
);
for
(
org
.
eclipse
.
titanium
.
metrics
.
MetricGroup
type
:
MetricGroup
.
values
())
{
for
(
MetricGroup
type
:
MetricGroup
.
values
())
{
Label
header
=
new
Label
(
page
,
0
);
header
.
setText
(
type
.
getGroupName
()
+
" metrics"
);
GridData
headerData
=
new
GridData
();
...
...
org.eclipse.titanium/src/org/eclipse/titanium/preferences/pages/RiskFactorPreferencePage.java
View file @
7e15c5b0
...
...
@@ -215,11 +215,11 @@ public class RiskFactorPreferencePage extends PreferencePage implements IWorkben
return
prefStore
;
}
static
void
insertSP
(
final
CodeSmellType
p
)
{
private
static
void
insertSP
(
final
CodeSmellType
p
)
{
USED_MARKERS
.
put
(
p
.
name
(),
p
.
getHumanReadableName
());
}
static
void
insertTask
(
final
TaskType
p
)
{
private
static
void
insertTask
(
final
TaskType
p
)
{
USED_MARKERS
.
put
(
p
.
name
(),
p
.
getHumanReadableName
());
}
}
\ No newline at end of file
org.eclipse.titanium/src/org/eclipse/titanium/utils/LocationHighlighter.java
View file @
7e15c5b0
...
...
@@ -38,7 +38,7 @@ public final class LocationHighlighter {
try
{
final
IWorkbenchPage
page
=
PlatformUI
.
getWorkbench
().
getActiveWorkbenchWindow
().
getActivePage
();
final
IEditorPart
editorPart
=
page
.
openEditor
(
new
FileEditorInput
((
IFile
)
location
.
getFile
()),
desc
.
getId
());
if
(
editorPart
!=
null
&&
(
editorPart
instanceof
AbstractTextEditor
)
)
{
if
(
editorPart
!=
null
&&
editorPart
instanceof
AbstractTextEditor
)
{
((
AbstractTextEditor
)
editorPart
).
setHighlightRange
(
location
.
getOffset
(),
0
,
true
);
}
...
...
org.eclipse.titanium/src/org/eclipse/titanium/utils/ProjectAnalyzerJob.java
View file @
7e15c5b0
...
...
@@ -58,12 +58,13 @@ public class ProjectAnalyzerJob extends WorkspaceJob {
*/
@Override
public
final
IStatus
runInWorkspace
(
final
IProgressMonitor
monitor
)
{
SubMonitor
progress
=
SubMonitor
.
convert
(
monitor
,
100
);
final
SubMonitor
progress
=
SubMonitor
.
convert
(
monitor
,
100
);
if
(
project
==
null
)
{
return
new
Status
(
IStatus
.
ERROR
,
Activator
.
PLUGIN_ID
,
"Project not specified for ProjectAnalyzerJob"
);
}
ProjectSourceParser
parser
=
GlobalParser
.
getProjectSourceParser
(
project
);
WorkspaceJob
job
=
parser
.
analyzeAll
();
final
ProjectSourceParser
parser
=
GlobalParser
.
getProjectSourceParser
(
project
);
final
WorkspaceJob
job
=
parser
.
analyzeAll
();
if
(
job
==
null
)
{
// maybe parsing is disabled
Display
.
getDefault
().
syncExec
(
new
Runnable
()
{
...
...
@@ -72,7 +73,7 @@ public class ProjectAnalyzerJob extends WorkspaceJob {
final
Display
disp
=
Display
.
getDefault
();
final
Shell
shell
=
new
Shell
(
disp
,
SWT
.
SHELL_TRIM
);
shell
.
setText
(
"Unavailable operation"
);
String
errorMessage
=
"This operation can not be executed while project parsing is disabled.\n\n"
final
String
errorMessage
=
"This operation can not be executed while project parsing is disabled.\n\n"
+
"Please enable parsing on the preference page: Window/Preferences/ TITAN Preferences/"
+
"On-the-fly checker/ Enable parsing of TTCN-3, ASN.1 and Runtime Configuration files"
;
MessageDialog
.
openInformation
(
shell
,
"Confronting settings"
,
errorMessage
);
...
...
@@ -81,7 +82,7 @@ public class ProjectAnalyzerJob extends WorkspaceJob {
return
Status
.
CANCEL_STATUS
;
}
IStatus
preStatus
=
doPreWork
(
progress
.
newChild
(
20
));
final
IStatus
preStatus
=
doPreWork
(
progress
.
newChild
(
20
));
progress
.
setWorkRemaining
(
80
);
if
(!
preStatus
.
isOK
())
{
return
preStatus
;
...
...
org.eclipse.titanium/src/org/eclipse/titanium/utils/ProjectStructureExporter.java
View file @
7e15c5b0
...
...
@@ -46,7 +46,7 @@ public class ProjectStructureExporter {
@Override
public
boolean
visit
(
final
IResource
resource
)
throws
CoreException
{
ResourceData
data
=
new
ResourceData
();
final
ResourceData
data
=
new
ResourceData
();
switch
(
resource
.
getType
())
{
case
IResource
.
PROJECT
:
...
...
@@ -82,7 +82,7 @@ public class ProjectStructureExporter {
}
public
void
saveTo
(
final
URI
path
)
throws
IOException
{
ResourceVisitor
visitor
=
new
ResourceVisitor
();
final
ResourceVisitor
visitor
=
new
ResourceVisitor
();
try
{
project
.
accept
(
visitor
);
}
catch
(
CoreException
e1
)
{
...
...
@@ -92,7 +92,7 @@ public class ProjectStructureExporter {
BufferedWriter
writer
=
null
;
try
{
writer
=
new
BufferedWriter
(
new
OutputStreamWriter
(
new
FileOutputStream
(
new
File
(
path
)),
"UTF-8"
));
MapAppender
appender
=
new
MapAppender
(
writer
,
StringUtils
.
lineSeparator
(),
";"
);
final
MapAppender
appender
=
new
MapAppender
(
writer
,
StringUtils
.
lineSeparator
(),
";"
);
for
(
ResourceData
data
:
visitor
.
resources
)
{
appender
.
append
(
data
.
type
,
data
.
projectRelativePath
,
data
.
absoluteURI
.
toString
());
}
...
...
org.eclipse.titanium/src/org/eclipse/titanium/utils/SonarDataExporter.java
View file @
7e15c5b0
...
...
@@ -57,8 +57,8 @@ public class SonarDataExporter {
final
URI
exportDir
=
URIUtil
.
append
(
projectLocation
,
".sonar_titanium"
);
System
.
out
.
println
(
"Export dir is: "
+
exportDir
.
getPath
());
final
File
f
=
new
File
(
exportDir
);
if
(!
f
.
exists
()
&&
!
f
.
mkdirs
())
{
final
File
f
ile
=
new
File
(
exportDir
);
if
(!
f
ile
.
exists
()
&&
!
f
ile
.
mkdirs
())
{
throw
new
IOException
(
"Cannot create output directory: "
+
exportDir
);
}
try
{
...
...
@@ -85,12 +85,12 @@ public class SonarDataExporter {
private
void
exportMetrics
(
final
URI
exportDir
)
throws
IOException
{
final
URI
filePath
=
URIUtil
.
append
(
exportDir
,
"metrics.xml"
);
final
File
f
=
new
File
(
filePath
);
FileUtils
.
delete
(
f
);
final
File
f
ile
=
new
File
(
filePath
);
FileUtils
.
delete
(
f
ile
);
final
SonarMetricsExporter
exporter
=
new
SonarMetricsExporter
();
try
{
exporter
.
export
(
MetricData
.
measure
(
project
),
f
);
exporter
.
export
(
MetricData
.
measure
(
project
),
f
ile
);
}
catch
(
JAXBException
e
)
{
new
ConsoleErrorHandler
().
reportException
(
"Error while exporting the project metrics"
,
e
);
}
...
...
@@ -135,8 +135,8 @@ public class SonarDataExporter {
private
void
exportCodeSmells
(
final
URI
exportDir
)
throws
IOException
{
final
URI
filePath
=
URIUtil
.
append
(
exportDir
,
"code_smells.csv"
);
final
File
f
=
new
File
(
filePath
);
FileUtils
.
delete
(
f
);
final
File
f
ile
=
new
File
(
filePath
);
FileUtils
.
delete
(
f
ile
);
final
BaseProblemExporter
exporter
=
new
SingleCsvProblemExporter
(
project
);
exporter
.
exportMarkers
(
new
NullProgressMonitor
(),
filePath
.
getPath
(),
Calendar
.
getInstance
().
getTime
());
}
...
...
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