Skip to content

Commit 414cf61

Browse files
author
SlavaRa
committed
Merge branch 'development' into feature/ExtractLocalVariable_improvements
2 parents 1cee99d + 364371e commit 414cf61

File tree

5 files changed

+21
-16
lines changed

5 files changed

+21
-16
lines changed

External/Plugins/CodeRefactor/PluginMain.cs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -379,33 +379,38 @@ private void UpdateMenuItems()
379379
refactorContextMenu.MoveMenuItem.Enabled = false;
380380
this.surroundContextMenu.Enabled = false;
381381
this.refactorMainMenu.SurroundMenu.Enabled = false;
382-
this.refactorContextMenu.ExtractMethodMenuItem.Enabled = false;
383-
this.refactorContextMenu.ExtractLocalVariableMenuItem.Enabled = false;
384382
this.refactorMainMenu.ExtractMethodMenuItem.Enabled = false;
383+
this.refactorContextMenu.ExtractMethodMenuItem.Enabled = false;
385384
this.refactorMainMenu.ExtractLocalVariableMenuItem.Enabled = false;
385+
this.refactorContextMenu.ExtractLocalVariableMenuItem.Enabled = false;
386386
ITabbedDocument document = PluginBase.MainForm.CurrentDocument;
387387
if (document != null && document.IsEditable && langIsValid)
388388
{
389389
bool isValidFile = IsValidFile(document.FileName);
390390
refactorMainMenu.MoveMenuItem.Enabled = isValidFile;
391391
refactorContextMenu.MoveMenuItem.Enabled = isValidFile;
392-
if (document.SciControl.SelTextSize > 1)
392+
var sci = document.SciControl;
393+
if (sci.SelTextSize > 0)
393394
{
394-
Int32 selEnd = document.SciControl.SelectionEnd;
395-
Int32 selStart = document.SciControl.SelectionStart;
396-
if (!document.SciControl.PositionIsOnComment(selEnd) || !document.SciControl.PositionIsOnComment(selStart))
395+
if (!sci.PositionIsOnComment(sci.SelectionStart) || !sci.PositionIsOnComment(sci.SelectionEnd))
397396
{
398397
this.surroundContextMenu.Enabled = true;
399398
this.refactorMainMenu.SurroundMenu.Enabled = true;
400-
this.refactorContextMenu.ExtractMethodMenuItem.Enabled = true;
401399
this.refactorMainMenu.ExtractMethodMenuItem.Enabled = true;
402-
this.refactorContextMenu.ExtractLocalVariableMenuItem.Enabled = true;
400+
this.refactorContextMenu.ExtractMethodMenuItem.Enabled = true;
401+
}
402+
var declAtSelStart = context.GetDeclarationAtLine(sci.LineFromPosition(sci.SelectionStart));
403+
var declAtSelEnd = context.GetDeclarationAtLine(sci.LineFromPosition(sci.SelectionEnd));
404+
if (declAtSelStart != null && declAtSelStart.Member != null && (declAtSelStart.Member.Flags & FlagType.Function) > 0
405+
&& declAtSelEnd != null && declAtSelStart.Member.Equals(declAtSelEnd.Member))
406+
{
403407
this.refactorMainMenu.ExtractLocalVariableMenuItem.Enabled = true;
408+
this.refactorContextMenu.ExtractLocalVariableMenuItem.Enabled = true;
404409
}
405410
}
406411
}
407-
this.refactorContextMenu.CodeGeneratorMenuItem.Enabled = isValid;
408412
this.refactorMainMenu.CodeGeneratorMenuItem.Enabled = isValid;
413+
this.refactorContextMenu.CodeGeneratorMenuItem.Enabled = isValid;
409414
}
410415
catch {}
411416
}

External/Plugins/DataEncoder/PluginMain.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public String LoadBinaryFile(String file)
192192
Object settings = new Object();
193193
MemoryStream stream = new MemoryStream();
194194
settings = ObjectSerializer.Deserialize(file, settings, false);
195-
XmlSerializer xs = new XmlSerializer(settings.GetType());
195+
XmlSerializer xs = XmlSerializer.FromTypes(new[]{settings.GetType()})[0];
196196
xs.Serialize(stream, settings); // Obj -> XML
197197
XmlTextWriter xw = new XmlTextWriter(stream, Encoding.UTF8);
198198
xw.Formatting = Formatting.Indented; stream.Close();
@@ -217,7 +217,7 @@ public void SaveBinaryFile(String file, String text)
217217
Byte[] buffer = Encoding.UTF8.GetBytes(text);
218218
MemoryStream stream = new MemoryStream(buffer);
219219
TypeData typeData = this.GetFileObjectType(file);
220-
XmlSerializer xs = new XmlSerializer(typeData.Type);
220+
XmlSerializer xs = XmlSerializer.FromTypes(new[]{typeData.Type})[0];
221221
settings = xs.Deserialize(stream); // XML -> Obj
222222
ObjectSerializer.Serialize(file, settings);
223223
stream.Close();

External/Plugins/FlashDebugger/Utilities.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ public class SerializeXML<T>
99
{
1010
public static void SaveFile(string filename, T obj)
1111
{
12-
XmlSerializer serializer1 = new XmlSerializer(typeof(T));
12+
XmlSerializer serializer1 = XmlSerializer.FromTypes(new[]{typeof(T)})[0];
1313
FileStream fs1 = new FileStream(filename, FileMode.Create);
1414
serializer1.Serialize(fs1, obj);
1515
fs1.Close();
1616
}
1717

1818
public static T LoadFile(string filename)
1919
{
20-
XmlSerializer serializer2 = new XmlSerializer(typeof(T));
20+
XmlSerializer serializer2 = XmlSerializer.FromTypes(new[]{typeof(T)})[0];
2121
FileStream fs2 = new FileStream(filename, FileMode.Open);
2222
T loadClasses = (T)serializer2.Deserialize(fs2);
2323
fs2.Close();
@@ -26,7 +26,7 @@ public static T LoadFile(string filename)
2626

2727
public static T LoadString(string s)
2828
{
29-
XmlSerializer serializer = new XmlSerializer(typeof(T));
29+
XmlSerializer serializer = XmlSerializer.FromTypes(new[]{typeof(T)})[0];
3030
StringReader str = new StringReader(s);
3131
T loadClasses = (T)serializer.Deserialize(str);
3232
str.Close();

External/Plugins/StartPage/ProjectInfo/RecentProjectList.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class RecentProjectList : List<RecentProject>
1111

1212
public RecentProjectList()
1313
{
14-
this.xmlSerializer = new XmlSerializer(this.GetType());
14+
this.xmlSerializer = XmlSerializer.FromTypes(new[]{this.GetType()})[0];
1515
}
1616
public RecentProjectList(List<String> recentProjects)
1717
{

PluginCore/ScintillaNet/Configuration/ConfigurationUtility.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected virtual Stream OpenFile(string filename, ConfigFile parent)
4747

4848
protected object Deserialize(TextReader reader, Type aType)
4949
{
50-
XmlSerializer xmlSerializer = new XmlSerializer(aType);
50+
XmlSerializer xmlSerializer = XmlSerializer.FromTypes(new[]{aType})[0];
5151
object local = xmlSerializer.Deserialize(reader);
5252
reader.Close();
5353
return local;

0 commit comments

Comments
 (0)