Skip to content

Commit ac8552d

Browse files
StuparStupar
Stupar
authored and
Stupar
committed
v1.6.1
1 parent 95ea6e5 commit ac8552d

File tree

12 files changed

+132
-131
lines changed

12 files changed

+132
-131
lines changed

source/shared/project/cppFiltersAutoShared.projitems

+3
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,15 @@
5353
<Compile Include="$(MSBuildThisFileDirectory)source\source\extension\filterToDir\filters.cs" />
5454
<Compile Include="$(MSBuildThisFileDirectory)source\source\extension\filterToDir\projectData.cs" />
5555
<Compile Include="$(MSBuildThisFileDirectory)source\source\extension\filterToDir\work.cs" />
56+
<Compile Include="$(MSBuildThisFileDirectory)source\source\other\test\dte\document.cs" />
57+
<Compile Include="$(MSBuildThisFileDirectory)source\source\other\test\dte\dte.cs" />
5658
<Compile Include="$(MSBuildThisFileDirectory)source\source\other\test\dte\project.cs" />
5759
<Compile Include="$(MSBuildThisFileDirectory)source\source\other\test\dte\projectItem.cs" />
5860
<Compile Include="$(MSBuildThisFileDirectory)source\source\other\test\other.cs" />
5961
<Compile Include="$(MSBuildThisFileDirectory)source\source\other\test\vc\file.cs" />
6062
<Compile Include="$(MSBuildThisFileDirectory)source\source\other\test\vc\filter.cs" />
6163
<Compile Include="$(MSBuildThisFileDirectory)source\source\other\test\vc\project.cs" />
64+
<Compile Include="$(MSBuildThisFileDirectory)source\source\other\test\vc\projectEngine.cs" />
6265
<Compile Include="$(MSBuildThisFileDirectory)source\source\other\test\vc\projectReference.cs" />
6366
<Compile Include="$(MSBuildThisFileDirectory)source\source\other\unused\project.cs" />
6467
<Compile Include="$(MSBuildThisFileDirectory)source\source\other\unused\xml.cs" />

source/shared/project/source/gui/questionFtd.Designer.cs

+12-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/shared/project/source/source/extension/dirToFilter/work.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ internal sealed partial class extension
2323
//callback
2424
void buttonBeforeQueryStatus(object sender, EventArgs e)
2525
{
26+
ThreadHelper.ThrowIfNotOnUIThread();
2627
OleMenuCommand x = (OleMenuCommand)sender;
2728
if (x == null) return;
2829

@@ -74,8 +75,8 @@ void buttonBeforeQueryStatus(object sender, EventArgs e)
7475
private void buttonClick(object sender, EventArgs e)
7576
{
7677
//projectData
77-
dirToFilter.ProjectData p = new dirToFilter.ProjectData();
7878
ThreadHelper.ThrowIfNotOnUIThread();
79+
dirToFilter.ProjectData p = new dirToFilter.ProjectData();
7980
p.p = projectUtility.GetActive();
8081

8182

source/shared/project/source/source/extension/filterToDir/error.cs

+13-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace filterToDir
1414

1515
public class error
1616
{
17-
public enum Type { move, delete, dirName, sameFile, sameFilter };
17+
public enum Type { move, delete, dirName, sameFile, sameFilter, existFile/*, fileSaved*/ };
1818

1919

2020

@@ -66,11 +66,22 @@ public override string ToString()
6666
s2 += "\r\nfilter contains multiple filters with the same name, please rename or move them:";
6767
s2 += "\r\n" + x2.s[0];
6868
break;
69+
70+
case Type.existFile:
71+
s2 += "\r\nfile path, included in project, does not exist:";
72+
s2 += "\r\n" + x2.s[0];
73+
s2 += "\r\n" + x2.s[1];
74+
break;
75+
/*case Type.fileSaved:
76+
s2 += "\r\nfiles that need to be moved are opened in editor, changed, but not saved. Please save or discard (close without save).";
77+
foreach (string s3 in x2.s)
78+
s2 += "\r\n" + s3;
79+
break;*/
6980
}
7081

71-
if (x2.e != null) s.Append("\r\n\r\nexception: [" + x2.e.Message + "]");
7282

7383
s.Append(s2);
84+
if (x2.e != null) s.Append("\r\n\r\nexception: [" + x2.e.Message + "]");
7485
if (i < x.Count - 1) s.Append("\r\n\r\n\r\n\r\n");
7586
}
7687

source/shared/project/source/source/extension/filterToDir/filters.cs

-76
Original file line numberDiff line numberDiff line change
@@ -127,82 +127,6 @@ public void init(VCProject p)
127127
}
128128

129129

130-
131-
132-
133-
134-
135-
/*public void fCleanEmpty(Dictionary<string, VCFile> filesIn, bool fEmptyDelete)
136-
{
137-
//remove from filters2
138-
foreach (var v in filesIn)
139-
{
140-
object o = v.Value.Parent;
141-
if (!(o is VCFilter)) continue;
142-
VCFilter f = (VCFilter)o;
143-
fAll[f.CanonicalName].files.Remove(v.Value.FullPath);
144-
v.Value.Move(p);
145-
}
146-
147-
//filters2 clean
148-
bool b;
149-
do
150-
{
151-
b = false;
152-
fAll = fAll.Where(x =>
153-
{
154-
filter2 x2 = x.Value;
155-
if (x2.files.Count != 0) return true;
156-
if (x2.filters2.Count != 0) return true;
157-
if (!fEmptyDelete) if (x2.fEmpty) return true;
158-
filter2 xp = x2.xp;
159-
xp.filters2.Remove(x2.xn2);
160-
x2.x.Remove();
161-
b = true;
162-
return false;
163-
}
164-
).ToDictionary(x => x.Key, x => x.Value);
165-
} while (b);
166-
167-
}*/
168-
169-
170-
171-
172-
173-
174-
175-
/*public filter2 fAdd(filter2 f, string x)
176-
{
177-
path x2 = new path(x, path.Separator.sDefault);
178-
179-
180-
filter2 x3 = f;
181-
for (int i = 0; i < x2.x2.Length; i++)
182-
{
183-
if (!x3.filters2.TryGetValue(x2.x2[i], out filter2 x4))
184-
{
185-
VCFilter x5 = null;
186-
if (x3.x == null)
187-
x5 = (VCFilter)p.AddFilter(x2.x2[i]);
188-
else
189-
x5 = (VCFilter)x3.x.AddFilter(x2.x2[i]);
190-
191-
x4 = new filter2() { x = x5 };
192-
x4.xp = x3;
193-
x3.filters2.Add(x5.Name, x4);
194-
fAll.Add(x5.CanonicalName, x4);
195-
196-
x4.xn = x5.CanonicalName;
197-
x4.xn2 = x5.Name;
198-
}
199-
x3 = x4;
200-
}
201-
return x3;
202-
}*/
203-
204-
205-
206130
}
207131
}
208132
}

source/shared/project/source/source/extension/filterToDir/projectData.cs

+49-23
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,18 @@ public void filesGet(Project p)
100100
private void check2(filter x, error e)
101101
{
102102
//chars
103-
bool b = true;
104-
foreach (char c in checkC)
105-
if (x.xn2.Contains(c)) { b = false; break; }
106-
if (!b) e.add(new error.data() { t = error.Type.dirName, s = new string[] { x.xn.x } });
103+
if (x.xn2 != null)
104+
{
105+
bool b = true;
106+
foreach (char c in checkC)
107+
if (x.xn2.Contains(c)) { b = false; break; }
108+
if (!b) e.add(new error.data() { t = error.Type.dirName, s = new string[] { x.xn.x } });
109+
}
110+
111+
112+
//exist file
113+
foreach (var x3 in x.o.files.Where(x2 => !File.Exists(x2.Key)))
114+
e.add(new error.data() { t = error.Type.existFile, s = new string[] { "path: " + x3.Key, "filter: " + dir.file2.fileRelative(x3.Value).x } });
107115

108116
//same file
109117
foreach (var x3 in x.o.files.GroupBy(x2 => dir.file2.fileRelative(x2.Value).x.ToLower()).Where(x2 => x2.Count() > 1))
@@ -118,11 +126,8 @@ private void check2(filter x, error e)
118126
check2(x2, e);
119127
}
120128

121-
public void check(error e)
122-
{
123-
foreach (filter x in f2.f.o.filters2)
124-
check2(x, e);
125-
}
129+
public void check(error e) => check2(f2.f, e);
130+
126131
}
127132
public Files f = new Files();
128133

@@ -264,37 +269,48 @@ public class file2
264269

265270
public class Configuration
266271
{
272+
public string itemType;
273+
//public string contentType; //contentType can not be empty string or start with null char
267274
public eFileType fileType;
275+
268276
public bool deploymentContent;
269277
//public string customTool;
270278
//public bool includedInProject;
271279

272280
public bool document = false;
273-
public string dGuid;
281+
274282
public Configuration(VCFile x)
275283
{
284+
itemType = x.ItemType;
285+
//contentType = x.ContentType;
276286
fileType = x.FileType;
287+
277288
deploymentContent = x.DeploymentContent;
278289
//customTool = x.CustomTool;
290+
//includedInProject
279291

280-
ProjectItem x2 = (ProjectItem)x.Object;
281-
//if (!x2.Saved) x2.Save(); notImplemented
282-
Document x3 = x2.Document;
283-
if (x3 != null)
292+
Document x2 = ((ProjectItem)x.Object).Document;
293+
if (x2 != null)
284294
{
285295
document = true;
286-
dGuid = x3.Kind;
296+
x2.Close(); //if (!x2.Saved) x2.Save(); notImplemented
287297
}
288298
}
289299
public void set(VCFile x)
290300
{
291301
if (x == null) return;
302+
303+
x.ItemType = itemType;
304+
//x.ContentType = contentType;
292305
x.FileType = fileType;
306+
293307
x.DeploymentContent = deploymentContent;
294308
//x.CustomTool = customTool; notImplemented
295-
296-
ProjectItem x2 = (ProjectItem)x.Object;
297-
if (document) x2.Open();
309+
//includedInProject
310+
311+
if (document)
312+
try { ((ProjectItem)x.Object).DTE.Documents.Open(x.FullPath); } //((ProjectItem)x.Object).Open(Document.Kind {8E7B96A8-E33D-11D0-A6D5-00C04FB67F6A} );
313+
catch (Exception) { }
298314
}
299315
}
300316

@@ -333,16 +349,17 @@ public bool move(ProjectData p, error e)
333349
{
334350
if (File.Exists(p2.x)) return false;
335351

336-
object o = f.xp.x;
337-
bool b = o != null;
352+
VCFilter x = f.xp.x;
353+
bool b = x != null;
354+
path p3 = p2;
338355

339356
Configuration c = new Configuration(f.x);
340357
{
341-
if (b) ((VCFilter)o).RemoveFile(f.x); else p.p.p.RemoveFile(f.x);
358+
if (b) x.RemoveFile(f.x); else p.p.p.RemoveFile(f.x);
342359
{
343-
if (!file2.move(p1, p2, e)) p2 = p1;
360+
if (!file2.move(p1, p2, e)) p3 = p1;
344361
}
345-
f.x = (VCFile)(b ? ((VCFilter)o).AddFile(p2.x) : p.p.p.AddFile(p2.x));
362+
f.x = (VCFile)(b ? x.AddFile(p3.x) : p.p.p.AddFile(p3.x));
346363
}
347364
c.set(f.x);
348365
return true;
@@ -538,6 +555,15 @@ public void init(error e)
538555
LinkedList<file2> x1 = new LinkedList<file2>();
539556
file2.filesGet(root, p.f.f2.f, ref x1);
540557
x = x1.ToArray();
558+
//error
559+
/*{
560+
file2[] x4 = x.Where(x3 => !((ProjectItem)x3.f.x.Object).).ToArray();
561+
if (x4.Length > 0)
562+
{
563+
e.add(new error.data() { t = error.Type.fileSaved, s = x4.Select(x3 => x3.p1.x).ToArray() });
564+
return;
565+
}
566+
}*/
541567
}
542568

543569
HashSet<dir2> x2 = new HashSet<dir2>();

source/shared/project/source/source/extension/filterToDir/work.cs

+8-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ internal sealed partial class extension
2222
private void button2Click(object sender, EventArgs e)
2323
{
2424
//project
25+
ThreadHelper.ThrowIfNotOnUIThread();
2526
filterToDir.ProjectData p = new filterToDir.ProjectData();
2627
{
27-
ThreadHelper.ThrowIfNotOnUIThread();
2828
Project x = projectUtility.GetActive();
2929

3030
//check 1 project
@@ -79,7 +79,13 @@ private void button2Click(object sender, EventArgs e)
7979

8080

8181
//dir
82-
if (!p.e.full) p.dirSet();
82+
if (!p.e.full)
83+
{
84+
projectUtility.documentsRefresh();
85+
string dn = projectUtility.dte.ActiveDocument?.Name;
86+
p.dirSet();
87+
projectUtility.documentActivate(dn);
88+
}
8389

8490

8591

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+


source/shared/project/source/source/other/test/other.cs

-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ public static void stringsInit(int i)
3636

3737

3838

39-
40-
4139
public static void pathSeparator()
4240
{
4341
//DirectorySeparatorChar \
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+


0 commit comments

Comments
 (0)