-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathJavaReferenceContainerNode.cs
More file actions
93 lines (79 loc) · 3.12 KB
/
Copy pathJavaReferenceContainerNode.cs
File metadata and controls
93 lines (79 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
namespace Tvl.VisualStudio.Language.Java.Project
{
using System;
using System.Collections.ObjectModel;
using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio.Project;
using File = System.IO.File;
using Path = System.IO.Path;
using VSCOMPONENTSELECTORDATA = Microsoft.VisualStudio.Shell.Interop.VSCOMPONENTSELECTORDATA;
[ComVisible(true)]
public class JavaReferenceContainerNode : ReferenceContainerNode
{
private static ReadOnlyCollection<string> _supportedReferenceTypes =
new ReadOnlyCollection<string>(new string[]
{
ProjectFileConstants.ProjectReference,
JavaProjectFileConstants.JarReference,
JavaProjectFileConstants.MavenReference,
});
public JavaReferenceContainerNode(JavaProjectNode root)
: base(root)
{
Contract.Requires<ArgumentNullException>(root != null, "root");
}
protected override ReadOnlyCollection<string> SupportedReferenceTypes
{
get
{
return _supportedReferenceTypes;
}
}
protected override ReferenceNode CreateFileComponent(VSCOMPONENTSELECTORDATA selectorData, string wrapperTool = null)
{
if (File.Exists(selectorData.bstrFile))
{
if (string.Equals(Path.GetExtension(selectorData.bstrFile), ".jar", StringComparison.OrdinalIgnoreCase))
{
return CreateJarReferenceNode(selectorData.bstrFile);
}
else
{
throw new InvalidOperationException("Cannot add a file reference to a non-jar file.");
}
}
return base.CreateFileComponent(selectorData, wrapperTool);
}
protected override ReferenceNode CreateReferenceNode(string referenceType, ProjectElement element)
{
switch (referenceType)
{
case ProjectFileConstants.ProjectReference:
return CreateProjectReferenceNode(element);
case JavaProjectFileConstants.JarReference:
return CreateJarReferenceNode(element);
case JavaProjectFileConstants.MavenReference:
return CreateMavenReferenceNode(element);
default:
return null;
}
}
protected virtual ReferenceNode CreateJarReferenceNode(ProjectElement element)
{
return new JarReferenceNode(ProjectManager, element);
}
protected virtual ReferenceNode CreateMavenReferenceNode(ProjectElement element)
{
throw new NotImplementedException();
}
protected virtual ReferenceNode CreateJarReferenceNode(string fileName)
{
return new JarReferenceNode(ProjectManager, fileName);
}
protected virtual ReferenceNode CreateMavenReferenceNode(string fileName)
{
throw new NotImplementedException();
}
}
}