Skip to content

Commit af853be

Browse files
author
SlavaRa
committed
Replace 'string_value != null && string_value.Length > 0' by '!string.isNullOrEmpty(string_value)'
1 parent 6534a86 commit af853be

File tree

27 files changed

+75
-73
lines changed

27 files changed

+75
-73
lines changed

External/Plugins/ASCompletion/Completion/ASComplete.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1868,7 +1868,7 @@ static private bool HandleDotCompletion(ScintillaControl Sci, bool autoHide)
18681868
int line = Sci.LineFromPosition(position);
18691869
if (cMember == null && !ASContext.Context.CurrentClass.IsVoid())
18701870
{
1871-
if (expr.Value != null && expr.Value.Length > 0)
1871+
if (!string.IsNullOrEmpty(expr.Value))
18721872
return HandleDeclarationCompletion(Sci, expr.Value, autoHide);
18731873
else if (ASContext.Context.CurrentModel.Version >= 2)
18741874
return ASGenerator.HandleGeneratorCompletion(Sci, autoHide, features.overrideKey);
@@ -3613,7 +3613,7 @@ private static ComaExpression DisambiguateComa(ScintillaControl Sci, int positio
36133613
static public MemberList ParseLocalVars(ASExpr expression)
36143614
{
36153615
FileModel model;
3616-
if (expression.FunctionBody != null && expression.FunctionBody.Length > 0)
3616+
if (!string.IsNullOrEmpty(expression.FunctionBody))
36173617
{
36183618
MemberModel cm = expression.ContextMember;
36193619
string functionBody = Regex.Replace(expression.FunctionBody, "function\\s*\\(", "function __anonfunc__("); // name anonymous functions

External/Plugins/ASCompletion/Completion/ASDocumentation.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ static public string GetTipShortDetails(CommentBlock cb, string highlightParam)
430430
string details = "";
431431

432432
// get parameter detail
433-
if (highlightParam != null && highlightParam.Length > 0 && cb.ParamName != null)
433+
if (!string.IsNullOrEmpty(highlightParam) && cb.ParamName != null)
434434
{
435435
for(int i=0; i<cb.ParamName.Count; i++)
436436
{
@@ -445,9 +445,9 @@ static public string GetTipShortDetails(CommentBlock cb, string highlightParam)
445445
// get description extract
446446
if (ASContext.CommonSettings.SmartTipsEnabled)
447447
{
448-
if (cb.InfoTip != null && cb.InfoTip.Length > 0)
448+
if (!string.IsNullOrEmpty(cb.InfoTip))
449449
details += "\n"+cb.InfoTip;
450-
else if (cb.Description != null && cb.Description.Length > 0)
450+
else if (!string.IsNullOrEmpty(cb.Description))
451451
details += Get2LinesOf(cb.Description, cb.IsFunctionWithArguments);
452452
}
453453

External/Plugins/ASCompletion/Completion/ASGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2166,7 +2166,7 @@ private static int GetContextOwnerEndPos(ScintillaControl Sci, int worsStartPos)
21662166

21672167
static public string Capitalize(string name)
21682168
{
2169-
return name != null && name.Length > 0 ? Char.ToUpper(name[0]) + name.Substring(1) : name;
2169+
return !string.IsNullOrEmpty(name) ? Char.ToUpper(name[0]) + name.Substring(1) : name;
21702170
}
21712171

21722172
static public string Camelize(string name)
@@ -3098,7 +3098,7 @@ private static string GuessVarName(string name, string type)
30983098

30993099
if (name == "this" || type == name)
31003100
{
3101-
if (type != null && type.Length > 0)
3101+
if (!string.IsNullOrEmpty(type))
31023102
name = Char.ToLower(type[0]) + type.Substring(1);
31033103
else
31043104
name = "p_this";

External/Plugins/ASCompletion/Completion/TemplateUtils.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static string ToDeclarationString(MemberModel m, string template)
7575
// If method, insert arguments
7676
template = ReplaceTemplateVariable(template, "Arguments", ParametersString(m, true));
7777

78-
if (m.Type != null && m.Type.Length > 0)
78+
if (!string.IsNullOrEmpty(m.Type))
7979
{
8080
if ((m.Flags & FlagType.Setter) > 0 && m.Parameters != null && m.Parameters.Count == 1)
8181
template = ReplaceTemplateVariable(template, "Type", FormatType(m.Parameters[0].Type));
@@ -111,7 +111,7 @@ public static string ParametersString(MemberModel member, bool formated)
111111

112112
one = ReplaceTemplateVariable(one, "PName", param.Name);
113113

114-
if (param.Type != null && param.Type.Length > 0)
114+
if (!string.IsNullOrEmpty(param.Type))
115115
one = ReplaceTemplateVariable(one, "PType", formated ? FormatType(param.Type) : param.Type);
116116
else
117117
one = ReplaceTemplateVariable(one, "PType", null);

External/Plugins/ASCompletion/CustomControls/ModelsExplorer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ private void updateTimer_Tick(object sender, EventArgs e)
432432

433433
private void FindPrevMatch(string search)
434434
{
435-
if (search != null && allTypes != null && search.Length > 0)
435+
if (!string.IsNullOrEmpty(search) && allTypes != null)
436436
{
437437
typeIndex--;
438438
if (typeIndex <= 0) typeIndex = allTypes.Count;
@@ -452,7 +452,7 @@ private void FindPrevMatch(string search)
452452

453453
private void FindNextMatch(string search)
454454
{
455-
if (search != null && allTypes != null && search.Length > 0)
455+
if (!string.IsNullOrEmpty(search) && allTypes != null)
456456
{
457457
while (typeIndex < allTypes.Count)
458458
{

External/Plugins/ASCompletion/Model/ASFileParser.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ private static MemberModel extractTypedCallbackModel(string comment)
244244
for (i = 0; i < l; i++)
245245
{
246246
string pName = pMatches[i].Groups["pName"].Value;
247-
if (pName != null && pName.Length > 0)
247+
if (!string.IsNullOrEmpty(pName))
248248
{
249249
foreach (KeyValuePair<String,String> replEntry in qStrRepls)
250250
{
@@ -257,7 +257,7 @@ private static MemberModel extractTypedCallbackModel(string comment)
257257
}
258258

259259
string pType = pMatches[i].Groups["pType"].Value;
260-
if (pType != null && pType.Length > 0)
260+
if (!string.IsNullOrEmpty(pType))
261261
{
262262
foreach (KeyValuePair<String,String> replEntry in qStrRepls)
263263
{
@@ -270,7 +270,7 @@ private static MemberModel extractTypedCallbackModel(string comment)
270270
}
271271

272272
string pVal = pMatches[i].Groups["pVal"].Value;
273-
if (pVal != null && pVal.Length > 0)
273+
if (!string.IsNullOrEmpty(pVal))
274274
{
275275
if (qStrRepls.ContainsKey(pVal))
276276
{

External/Plugins/ASCompletion/Model/ClassModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ static public string ClassDeclaration(ClassModel ofClass, bool qualified)
448448
else modifiers += "intrinsic ";
449449
}
450450
else if (ofClass.InFile.Version > 2)
451-
if (ofClass.Namespace != null && ofClass.Namespace.Length > 0
451+
if (!string.IsNullOrEmpty(ofClass.Namespace)
452452
&& ofClass.Namespace != "internal")
453453
{
454454
// if ((ft & FlagType.Interface) == 0)
@@ -502,7 +502,7 @@ static public string MemberDeclaration(MemberModel member, bool preventVisibilit
502502
if ((ft & FlagType.Extern) > 0) modifiers += "extern ";
503503
else modifiers += "intrinsic ";
504504
}
505-
else if (member.Namespace != null && member.Namespace.Length > 0
505+
else if (!string.IsNullOrEmpty(member.Namespace)
506506
&& member.Namespace != "internal")
507507
{
508508
if ((ft & FlagType.Interface) == 0)

External/Plugins/ASCompletion/Model/MemberModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public string ToDeclarationString(bool wrapWithSpaces, bool concatValue)
140140
if (Parameters != null && Parameters.Count > 0)
141141
{
142142
comment = "/*(" + ParametersString(true) + ")";
143-
if (Type != null && Type.Length > 0)
143+
if (!string.IsNullOrEmpty(Type))
144144
comment += colon + FormatType(Type);
145145
comment += "*/";
146146
}
@@ -151,12 +151,12 @@ public string ToDeclarationString(bool wrapWithSpaces, bool concatValue)
151151
}
152152
}
153153

154-
if ((type == null || type.Length == 0) && (Type != null && Type.Length > 0))
154+
if (string.IsNullOrEmpty(type) && !string.IsNullOrEmpty(Type))
155155
type = FormatType(Type);
156156

157157
if ((Flags & FlagType.Constructor) > 0)
158158
return res;
159-
else if (type != null && type.Length > 0)
159+
else if (!string.IsNullOrEmpty(type))
160160
res += colon + type;
161161

162162
res += comment;

External/Plugins/ASCompletion/PluginUI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ private void AddExtend(TreeNodeCollection tree, ClassModel aClass)
741741
//if ((aClass.Flags & FlagType.TypeDef) > 0 && aClass.Members.Count == 0)
742742
// folder.Text = "Defines"; // TODO need a better word I guess
743743

744-
while (aClass.ExtendsType != null && aClass.ExtendsType.Length > 0
744+
while (!string.IsNullOrEmpty(aClass.ExtendsType)
745745
&& aClass.ExtendsType != "Object"
746746
&& (!aClass.InFile.haXe || aClass.ExtendsType != "Dynamic"))
747747
{

External/Plugins/ProjectManager/Controls/NewProjectDialog.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ void NewProjectDialog_Load(object sender, EventArgs e)
362362
createDirectoryBox.Checked = PluginMain.Settings.CreateProjectDirectory;
363363

364364
string locationDir = PluginMain.Settings.NewProjectDefaultDirectory;
365-
if (locationDir != null && locationDir.Length > 0 && Directory.Exists(locationDir))
365+
if (!string.IsNullOrEmpty(locationDir) && Directory.Exists(locationDir))
366366
locationTextBox.Text = locationDir;
367367
else locationTextBox.Text = ProjectPaths.DefaultProjectsDirectory;
368368
locationTextBox.SelectionStart = locationTextBox.Text.Length;

0 commit comments

Comments
 (0)