Browse Source

Fixed SD2-1276: Duplicated code when converting single VB.NET If-Then line into multiple lines

Use AddInTree to let AddIns register additional MSBuild properties.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.1@2380 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
20cbe02631
  1. 10
      src/AddIns/BackendBindings/Boo/BooBinding/Project/BooBinding.addin
  2. 6
      src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/BooProject.cs
  3. 2
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBNetFormattingStrategy.cs
  4. 25
      src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs
  5. 23
      src/Main/Base/Project/Src/Project/MSBuildEngine.cs
  6. 10
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/ConstructedReturnType.cs

10
src/AddIns/BackendBindings/Boo/BooBinding/Project/BooBinding.addin

@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
<Import assembly = ":ICSharpCode.SharpDevelop"/>
</Runtime>
<!-- Add the "Boo" entry to the Open Project Dialog -->
<Path name = "/SharpDevelop/Workbench/Combine/FileFilter">
<FileFilter id = "BooProject"
insertbefore="AllFiles"
@ -23,6 +24,7 @@ @@ -23,6 +24,7 @@
extensions = "*.booproj"/>
</Path>
<!-- Add the "Boo" entry to the Open File Dialog -->
<Path name = "/SharpDevelop/Workbench/FileFilter">
<FileFilter id = "Boo"
insertbefore="AllFiles"
@ -30,11 +32,17 @@ @@ -30,11 +32,17 @@
extensions = "*.boo"/>
</Path>
<!-- Makes SharpDevelop show the text 'Compiling ProjectName...' whenever an MSBuild task named 'booc' is started -->
<Path name = "/SharpDevelop/MSBuildEngine/CompileTaskNames">
<!-- Makes SharpDevelop show the text 'Compiling ProjectName...' when the task is started -->
<String id="booc" text = "booc"/>
</Path>
<!-- Register path to Boo.Microsoft.Build.targets for MSBuild engine. -->
<!-- Boo.Microsoft.Build.targets are in the AddIn directory -->
<Path name = "/SharpDevelop/MSBuildEngine/AdditionalProperties">
<String id="BooBinPath" text = "${AddInPath:ICSharpCode.BooBinding}"/>
</Path>
<Path name = "/AddIns/FileTypeRegisterer/FileTypes">
<FiletypeAssociation
id = "booproj"

6
src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/BooProject.cs

@ -18,17 +18,11 @@ namespace Grunwald.BooBinding @@ -18,17 +18,11 @@ namespace Grunwald.BooBinding
{
public class BooProject : CompilableProject
{
static bool initialized = false;
public static readonly string BooBinPath = Path.GetDirectoryName(typeof(BooProject).Assembly.Location);
void Init()
{
reparseCodeSensitiveProperties.Add("Ducky");
if (!initialized) {
initialized = true;
MSBuildEngine.MSBuildProperties.Add("BooBinPath", BooBinPath);
}
}
public override string Language {

2
src/AddIns/BackendBindings/VBNetBinding/Project/Src/FormattingStrategy/VBNetFormattingStrategy.cs

@ -351,7 +351,7 @@ namespace VBNetBinding.FormattingStrategy @@ -351,7 +351,7 @@ namespace VBNetBinding.FormattingStrategy
if (Regex.IsMatch(texttoreplace.Trim(), statement.StartRegex, RegexOptions.IgnoreCase)) {
string indentation = GetIndentation(textArea, lineNr - 1);
if (isEndStatementNeeded(textArea, ref statement, lineNr)) {
textArea.Document.Insert(textArea.Caret.Offset, terminator + indentation + statement.EndStatement);
textArea.Document.Replace(curLine.Offset, curLine.Length, terminator + indentation + statement.EndStatement);
++undoCount;
}
for (int i = 0; i < statement.IndentPlus; i++) {

25
src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs

@ -820,9 +820,28 @@ namespace ICSharpCode.SharpDevelop.Project @@ -820,9 +820,28 @@ namespace ICSharpCode.SharpDevelop.Project
internal static void InitializeMSBuildProject(MSBuild.Project project)
{
project.GlobalProperties.SetProperty("BuildingInsideVisualStudio", "true");
foreach (KeyValuePair<string, string> pair in MSBuildEngine.MSBuildProperties) {
project.GlobalProperties.SetProperty(pair.Key, pair.Value, true);
InitializeMSBuildProjectProperties(project.GlobalProperties);
}
/// <summary>
/// Set compilation properties (MSBuildProperties and AddInTree/AdditionalPropertiesPath).
/// </summary>
internal static void InitializeMSBuildProjectProperties(MSBuild.BuildPropertyGroup propertyGroup)
{
foreach (KeyValuePair<string, string> entry in MSBuildEngine.MSBuildProperties) {
propertyGroup.SetProperty(entry.Key, entry.Value);
}
// re-load these properties from AddInTree every time because "text" might contain
// SharpDevelop properties resolved by the StringParser (e.g. ${property:FxCopPath})
AddInTreeNode node = AddInTree.GetTreeNode(MSBuildEngine.AdditionalPropertiesPath, false);
if (node != null) {
foreach (Codon codon in node.Codons) {
object item = codon.BuildItem(null, new System.Collections.ArrayList());
if (item != null) {
bool escapeValue = !codon.Properties.Get("text", "").Contains("$(");
propertyGroup.SetProperty(codon.Id, item.ToString(), escapeValue);
}
}
}
}

23
src/Main/Base/Project/Src/Project/MSBuildEngine.cs

@ -30,7 +30,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -30,7 +30,7 @@ namespace ICSharpCode.SharpDevelop.Project
const string CompileTaskNamesPath = "/SharpDevelop/MSBuildEngine/CompileTaskNames";
const string AdditionalTargetFilesPath = "/SharpDevelop/MSBuildEngine/AdditionalTargetFiles";
const string AdditionalLoggersPath = "/SharpDevelop/MSBuildEngine/AdditionalLoggers";
const string AdditionalPropertiesPath = "/SharpDevelop/MSBuildEngine/AdditionalProperties";
internal const string AdditionalPropertiesPath = "/SharpDevelop/MSBuildEngine/AdditionalProperties";
/// <summary>
/// Gets a list of the task names that cause a "Compiling ..." log message.
@ -69,6 +69,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -69,6 +69,7 @@ namespace ICSharpCode.SharpDevelop.Project
MSBuildProperties = new SortedList<string, string>();
MSBuildProperties.Add("SharpDevelopBinPath", Path.GetDirectoryName(typeof(MSBuildEngine).Assembly.Location));
MSBuildProperties.Add("BuildingInsideVisualStudio", "true");
}
#region Properties
@ -373,21 +374,9 @@ namespace ICSharpCode.SharpDevelop.Project @@ -373,21 +374,9 @@ namespace ICSharpCode.SharpDevelop.Project
internal Engine CreateEngine()
{
Engine engine = MSBuildInternals.CreateEngine();
foreach (KeyValuePair<string, string> entry in MSBuildProperties) {
engine.GlobalProperties.SetProperty(entry.Key, entry.Value);
}
// re-load these properties from AddInTree every time because "text" might contain
// SharpDevelop properties resolved by the StringParser (e.g. ${property:FxCopPath})
AddInTreeNode node = AddInTree.GetTreeNode(AdditionalPropertiesPath, false);
if (node != null) {
foreach (Codon codon in node.Codons) {
object item = codon.BuildItem(null, new System.Collections.ArrayList());
if (item != null) {
bool escapeValue = !codon.Properties.Get("text", "").Contains("$(");
engine.GlobalProperties.SetProperty(codon.Id, item.ToString(), escapeValue);
}
}
}
MSBuildBasedProject.InitializeMSBuildProjectProperties(engine.GlobalProperties);
if (options.AdditionalProperties != null) {
foreach (KeyValuePair<string, string> entry in options.AdditionalProperties) {
engine.GlobalProperties.SetProperty(entry.Key, entry.Value);
@ -398,8 +387,6 @@ namespace ICSharpCode.SharpDevelop.Project @@ -398,8 +387,6 @@ namespace ICSharpCode.SharpDevelop.Project
engine.GlobalProperties.SetProperty("SolutionFileName", Path.GetFileName(solution.FileName));
engine.GlobalProperties.SetProperty("SolutionPath", solution.FileName);
engine.GlobalProperties.SetProperty("BuildingInsideVisualStudio", "true");
return engine;
}

10
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/ConstructedReturnType.cs

@ -72,17 +72,21 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -72,17 +72,21 @@ namespace ICSharpCode.SharpDevelop.Dom
}
}
/// <summary>
/// Gets if <paramref name="t"/> is/contains a generic return type referring to a class type parameter.
/// </summary>
bool CheckReturnType(IReturnType t)
{
if (t == null) {
return false;
}
if (t.IsGenericReturnType) {
return t.CastToGenericReturnType().TypeParameter.Method == null;
} else if (t.IsArrayReturnType) {
return CheckReturnType(t.CastToArrayReturnType().ArrayElementType);
} else if (t.IsConstructedReturnType) {
foreach (IReturnType para in t.CastToConstructedReturnType().TypeArguments) {
if (para != null) {
if (CheckReturnType(para)) return true;
}
if (CheckReturnType(para)) return true;
}
return false;
} else {

Loading…
Cancel
Save