Browse Source

Added feature: go to definition (Ctrl-Enter)

Set warninglevel to 4 for Core + Base (somehow it was set to 0 -> a bug in AbstractMember.cs was hidden)

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@78 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 21 years ago
parent
commit
c01804f7d2
  1. 5
      AddIns/ICSharpCode.SharpDevelop.addin
  2. 10
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj
  3. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj
  4. 2
      src/AddIns/Misc/Debugger/TreeListView/Project/TreeListView.csproj
  5. 65
      src/Libraries/DockPanel_Src/WinFormsUI/WinFormsUI.csproj
  6. 32
      src/Libraries/DockPanel_Src/WinFormsUI/WinFormsUI.csproj.user
  7. 2
      src/Libraries/NRefactory/Project/NRefactory.csproj
  8. 10
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  9. 2
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj.user
  10. 18
      src/Main/Base/Project/Src/Dom/FilePosition.cs
  11. 4
      src/Main/Base/Project/Src/Dom/IMember.cs
  12. 11
      src/Main/Base/Project/Src/Dom/Implementations/AbstractMember.cs
  13. 4
      src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs
  14. 70
      src/Main/Base/Project/Src/Dom/ResolveResult.cs
  15. 36
      src/Main/Base/Project/Src/TextEditor/Actions.cs
  16. 32
      src/Main/Base/Project/Src/TextEditor/Commands/NavigationCommands.cs
  17. 5
      src/Main/Base/Test/ICSharpCode.SharpDevelop.Tests.csproj
  18. 26
      src/Main/Base/Test/NRefactoryResolverTests.cs
  19. 6
      src/Main/Core/Project/ICSharpCode.Core.csproj

5
AddIns/ICSharpCode.SharpDevelop.addin

@ -1494,6 +1494,10 @@ @@ -1494,6 +1494,10 @@
label = "${res:XML.TextAreaContextMenu.Indent}"
shortcut = "Control|I"
class = "ICSharpCode.SharpDevelop.DefaultEditor.Commands.IndentSelection" />
<MenuItem id = "GoToDefinition"
label = "${res:XML.TextAreaContextMenu.GoToDefinition}"
shortcut = "Control|Enter"
class = "ICSharpCode.SharpDevelop.DefaultEditor.Commands.GoToDefinition" />
<MenuItem id = "FileMode" label = "${res:XML.TextAreaContextMenu.FileMode}" type="Menu">
<MenuItem id = "HighlightBuilder" type="Builder" class = "ICSharpCode.SharpDevelop.DefaultEditor.Commands.HighlightingTypeBuilder" />
@ -1738,6 +1742,7 @@ @@ -1738,6 +1742,7 @@
<EditAction id = "TemplateCompletion" class = "ICSharpCode.SharpDevelop.DefaultEditor.Actions.TemplateCompletion" keys = "Control|J"/>
<EditAction id = "CodeCompletionPopup" class = "ICSharpCode.SharpDevelop.DefaultEditor.Actions.CodeCompletionPopup" keys = "Control|Space"/>
<EditAction id = "IndentSelection" class = "ICSharpCode.TextEditor.Actions.IndentSelection" keys = "Control|I"/>
<EditAction id = "GoToDefinition" class = "ICSharpCode.SharpDevelop.DefaultEditor.Actions.GoToDefinition" keys = "Control|Enter"/>
</Path>
<Path name = "/SharpDevelop/Pads/BookmarkPad/Toolbar">

10
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@ -45,6 +45,9 @@ @@ -45,6 +45,9 @@
<SubType>Form</SubType>
</Compile>
<Compile Include="Src\Service\WindowsDebugger.cs" />
<EmbeddedResource Include="Src\Service\ExceptionForm.resx">
<DependentUpon>ExceptionForm.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj">
@ -73,10 +76,5 @@ @@ -73,10 +76,5 @@
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Src\Service\ExceptionForm.resx">
<DependentUpon>ExceptionForm.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
</Project>

4
src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@ -9,8 +9,6 @@ @@ -9,8 +9,6 @@
<RootNamespace>Debugger.Core</RootNamespace>
<AssemblyName>Debugger.Core</AssemblyName>
<WarningLevel>4</WarningLevel>
<AssemblyOriginatorKeyFile />
<AssemblyKeyProviderName />
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

2
src/AddIns/Misc/Debugger/TreeListView/Project/TreeListView.csproj

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>

65
src/Libraries/DockPanel_Src/WinFormsUI/WinFormsUI.csproj

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.41115</ProductVersion>
@ -6,10 +6,6 @@ @@ -6,10 +6,6 @@
<ProjectGuid>{D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon>
</ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>WeifenLuo.WinFormsUI.Docking</AssemblyName>
<AssemblyOriginatorKeyFile>..\..\..\Main\Core\Project\Resources\ICSharpCode.Core.snk</AssemblyOriginatorKeyFile>
<DefaultClientScript>JScript</DefaultClientScript>
@ -19,10 +15,6 @@ @@ -19,10 +15,6 @@
<OutputType>Library</OutputType>
<RootNamespace>WeifenLuo.WinFormsUI</RootNamespace>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<StartupObject>
</StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@ -30,15 +22,11 @@ @@ -30,15 +22,11 @@
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DocumentationFile>bin\Debug\CodeDoc.xml</DocumentationFile>
<DebugSymbols>true</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<NoStdLib>false</NoStdLib>
<NoWarn>
</NoWarn>
<Optimize>false</Optimize>
<RegisterForComInterop>false</RegisterForComInterop>
<RemoveIntegerChecks>false</RemoveIntegerChecks>
@ -50,16 +38,10 @@ @@ -50,16 +38,10 @@
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile>
</DocumentationFile>
<DebugSymbols>false</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<NoStdLib>false</NoStdLib>
<NoWarn>
</NoWarn>
<Optimize>true</Optimize>
<RegisterForComInterop>false</RegisterForComInterop>
<RemoveIntegerChecks>false</RemoveIntegerChecks>
@ -90,12 +72,9 @@ @@ -90,12 +72,9 @@
<Compile Include="AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Controls\InertButton.cs">
</Compile>
<Compile Include="Docking\AutoHideWindow.cs">
</Compile>
<Compile Include="Docking\AutoHideWindowSplitter.cs">
</Compile>
<Compile Include="Controls\InertButton.cs" />
<Compile Include="Docking\AutoHideWindow.cs" />
<Compile Include="Docking\AutoHideWindowSplitter.cs" />
<Compile Include="Docking\DisplayingDockList.cs">
<SubType>Code</SubType>
</Compile>
@ -120,28 +99,23 @@ @@ -120,28 +99,23 @@
<Compile Include="Docking\DockPaneCollection.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Docking\DockPanel.cs">
</Compile>
<Compile Include="Docking\DockPanel.cs" />
<Compile Include="Docking\DockPanelPersist.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Docking\DockPaneSplitter.cs">
</Compile>
<Compile Include="Docking\DockWindow.cs">
</Compile>
<Compile Include="Docking\DockPaneSplitter.cs" />
<Compile Include="Docking\DockWindow.cs" />
<Compile Include="Docking\DockWindowCollection.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Docking\DockWindowSplitter.cs">
</Compile>
<Compile Include="Docking\DockWindowSplitter.cs" />
<Compile Include="Docking\DragHandler.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Docking\DragHandlerBase.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Docking\DummyControl.cs">
</Compile>
<Compile Include="Docking\DummyControl.cs" />
<Compile Include="Docking\Enums.cs">
<SubType>Code</SubType>
</Compile>
@ -166,8 +140,7 @@ @@ -166,8 +140,7 @@
<Compile Include="Docking\NestedDockingStatus.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Docking\SplitterBase.cs">
</Compile>
<Compile Include="Docking\SplitterBase.cs" />
<Compile Include="Helpers\DrawHelper.cs">
<SubType>Code</SubType>
</Compile>
@ -203,6 +176,11 @@ @@ -203,6 +176,11 @@
<EmbeddedResource Include="Resources\DockPane.ToolWindowCloseDisabled.bmp" />
<EmbeddedResource Include="Resources\DockPane.ToolWindowCloseEnabled.bmp" />
<EmbeddedResource Include="Strings.resX" />
<None Include="..\..\..\Main\Core\Project\Resources\ICSharpCode.Core.snk">
<Link>ICSharpCode.Core.snk</Link>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="Controls\CodeDoc\InertButton.xml" />
<Content Include="Docking\CodeDoc\DisplayingDockList.xml" />
<Content Include="Docking\CodeDoc\DockContent.xml" />
@ -219,20 +197,7 @@ @@ -219,20 +197,7 @@
<Content Include="Docking\CodeDoc\FloatWindowCollection.xml" />
<Content Include="Docking\CodeDoc\Interfaces.xml" />
<Content Include="Docking\CodeDoc\NestedDockingStatus.xml" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\Main\Core\Project\Resources\ICSharpCode.Core.snk">
<Link>ICSharpCode.Core.snk</Link>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Configuration\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

32
src/Libraries/DockPanel_Src/WinFormsUI/WinFormsUI.csproj.user

@ -1,14 +1,8 @@ @@ -1,14 +1,8 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<LastOpenVersion>8.0.41115</LastOpenVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ReferencePath>
</ReferencePath>
<CopyProjectDestinationFolder>
</CopyProjectDestinationFolder>
<CopyProjectUncPath>
</CopyProjectUncPath>
<CopyProjectOption>0</CopyProjectOption>
<ProjectView>ProjectFiles</ProjectView>
<ProjectTrust>0</ProjectTrust>
@ -19,19 +13,7 @@ @@ -19,19 +13,7 @@
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
<EnableSQLServerDebugging>false</EnableSQLServerDebugging>
<RemoteDebugEnabled>false</RemoteDebugEnabled>
<RemoteDebugMachine>
</RemoteDebugMachine>
<StartAction>Project</StartAction>
<StartArguments>
</StartArguments>
<StartPage>
</StartPage>
<StartProgram>
</StartProgram>
<StartURL>
</StartURL>
<StartWorkingDirectory>
</StartWorkingDirectory>
<StartWithIE>true</StartWithIE>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
@ -40,19 +22,7 @@ @@ -40,19 +22,7 @@
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
<EnableSQLServerDebugging>false</EnableSQLServerDebugging>
<RemoteDebugEnabled>false</RemoteDebugEnabled>
<RemoteDebugMachine>
</RemoteDebugMachine>
<StartAction>Project</StartAction>
<StartArguments>
</StartArguments>
<StartPage>
</StartPage>
<StartProgram>
</StartProgram>
<StartURL>
</StartURL>
<StartWorkingDirectory>
</StartWorkingDirectory>
<StartWithIE>false</StartWithIE>
</PropertyGroup>
</Project>

2
src/Libraries/NRefactory/Project/NRefactory.csproj

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.41115</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{3a9ae6aa-bc07-4a2f-972c-581e3ae2f195}</ProjectGuid>
<ProjectGuid>{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}</ProjectGuid>
<RootNamespace>NewProject</RootNamespace>
<AssemblyName>ICSharpCode.NRefactory</AssemblyName>
<OutputTarget>Library</OutputTarget>

10
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -19,9 +19,9 @@ @@ -19,9 +19,9 @@
<Optimize>False</Optimize>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<OutputPath>..\..\..\..\bin\</OutputPath>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<RunFxCop>false</RunFxCop>
<WarningLevel>0</WarningLevel>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>False</DebugSymbols>
@ -29,7 +29,8 @@ @@ -29,7 +29,8 @@
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<OutputPath>..\..\..\..\bin\</OutputPath>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="ICSharpCode.SharpZipLib, Version=0.82.0.1709, Culture=neutral, PublicKeyToken=1b03e6acf1164f73">
@ -617,8 +618,9 @@ @@ -617,8 +618,9 @@
<Compile Include="Src\Project\AbstractProject.cs" />
<Compile Include="Src\Dom\XmlDoc.cs" />
<Compile Include="Src\Services\ParserService\ProjectContentRegistry.cs" />
<Compile Include="Src\Dom\NRefactoryResolver\FilePosition.cs" />
<Compile Include="Src\Dom\ResolveResult.cs" />
<Compile Include="Src\TextEditor\Commands\NavigationCommands.cs" />
<Compile Include="Src\Dom\FilePosition.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Libraries\DockPanel_Src\WinFormsUI\WinFormsUI.csproj">

2
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj.user

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
<PropertyGroup>

18
src/Main/Base/Project/Src/Dom/NRefactoryResolver/FilePosition.cs → src/Main/Base/Project/Src/Dom/FilePosition.cs

@ -10,20 +10,32 @@ @@ -10,20 +10,32 @@
using System;
using System.Drawing;
namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
namespace ICSharpCode.SharpDevelop.Dom
{
/// <summary>
/// Description of SearchDefinition.
/// </summary>
public class FilePosition
{
string filename = "";
Point position = new Point(0, 0);
string filename;
Point position;
public FilePosition(string filename, Point position)
{
this.filename = filename;
this.position = position;
}
public string Filename {
get {
return filename;
}
}
public Point Position {
get {
return position;
}
}
}
}

4
src/Main/Base/Project/Src/Dom/IMember.cs

@ -29,9 +29,5 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -29,9 +29,5 @@ namespace ICSharpCode.SharpDevelop.Dom
IReturnType ReturnType {
get;
}
IClass DeclaringType {
get;
}
}
}

11
src/Main/Base/Project/Src/Dom/Implementations/AbstractMember.cs

@ -12,9 +12,8 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -12,9 +12,8 @@ namespace ICSharpCode.SharpDevelop.Dom
[Serializable]
public abstract class AbstractMember : AbstractNamedEntity, IMember
{
protected IClass declaringType;
protected IReturnType returnType;
protected IRegion region;
protected IRegion region;
public virtual IRegion Region {
get {
@ -22,12 +21,6 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -22,12 +21,6 @@ namespace ICSharpCode.SharpDevelop.Dom
}
}
public IClass DeclaringType {
get {
return declaringType;
}
}
public virtual IReturnType ReturnType {
get {
return returnType;
@ -36,9 +29,9 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -36,9 +29,9 @@ namespace ICSharpCode.SharpDevelop.Dom
returnType = value;
}
}
public AbstractMember(IClass declaringType) : base(declaringType)
{
}
}
}

4
src/Main/Base/Project/Src/Dom/NRefactoryResolver/NRefactoryResolver.cs

@ -208,12 +208,12 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -208,12 +208,12 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
if (var != null) {
IReturnType type = GetVariableType(var);
IField field = new LocalVariableField(type, identifier, null, callingClass);
return new LocalResolveResult(callingClass, callingMember, field, false);
return new LocalResolveResult(callingMember, field, false);
}
IParameter para = SearchMethodParameter(identifier);
if (para != null) {
IField field = new LocalVariableField(para.ReturnType, para.Name, para.Region, callingClass);
return new LocalResolveResult(callingClass, callingMember, field, true);
return new LocalResolveResult(callingMember, field, true);
}
IMember member = GetMember(callingClass, identifier);
if (member != null) {

70
src/Main/Base/Project/Src/Dom/ResolveResult.cs

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.Core;
@ -79,6 +80,12 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -79,6 +80,12 @@ namespace ICSharpCode.SharpDevelop.Dom
return null;
return c.GetAccessibleMembers(callingClass, false);
}
public virtual FilePosition GetDefinitionPosition()
{
// this is only possible on some subclasses of ResolveResult
return null;
}
}
#endregion
@ -96,8 +103,8 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -96,8 +103,8 @@ namespace ICSharpCode.SharpDevelop.Dom
IField field;
bool isParameter;
public LocalResolveResult(IClass callingClass, IMember callingMember, IField field, bool isParameter)
: base(callingClass, callingMember, field.ReturnType)
public LocalResolveResult(IMember callingMember, IField field, bool isParameter)
: base(callingMember.DeclaringType, callingMember, field.ReturnType)
{
if (callingMember == null)
throw new ArgumentNullException("callingMember");
@ -124,6 +131,24 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -124,6 +131,24 @@ namespace ICSharpCode.SharpDevelop.Dom
return isParameter;
}
}
public override FilePosition GetDefinitionPosition()
{
ICompilationUnit cu = this.CallingClass.CompilationUnit;
if (cu == null) {
Console.WriteLine("callingClass.CompilationUnit is null");
return null;
}
if (cu.FileName == null || cu.FileName.Length == 0) {
Console.WriteLine("callingClass.CompilationUnit.FileName is empty");
return null;
}
IRegion reg = field.Region;
if (reg != null)
return new FilePosition(cu.FileName, new Point(reg.BeginLine, reg.BeginColumn));
else
return new FilePosition(cu.FileName, Point.Empty);
}
}
#endregion
@ -203,6 +228,24 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -203,6 +228,24 @@ namespace ICSharpCode.SharpDevelop.Dom
else
return resolvedClass.GetAccessibleMembers(this.CallingClass, true);
}
public override FilePosition GetDefinitionPosition()
{
ICompilationUnit cu = resolvedClass.CompilationUnit;
if (cu == null) {
Console.WriteLine("resolvedClass.CompilationUnit is null");
return null;
}
if (cu.FileName == null || cu.FileName.Length == 0) {
Console.WriteLine("resolvedClass.CompilationUnit.FileName is empty");
return null;
}
IRegion reg = resolvedClass.Region;
if (reg != null)
return new FilePosition(cu.FileName, new Point(reg.BeginLine, reg.BeginColumn));
else
return new FilePosition(cu.FileName, Point.Empty);
}
}
#endregion
@ -243,6 +286,29 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -243,6 +286,29 @@ namespace ICSharpCode.SharpDevelop.Dom
return resolvedMember;
}
}
public override FilePosition GetDefinitionPosition()
{
IClass declaringType = resolvedMember.DeclaringType;
if (declaringType == null) {
Console.WriteLine("declaringType is null");
return null;
}
ICompilationUnit cu = declaringType.CompilationUnit;
if (cu == null) {
Console.WriteLine("declaringType.CompilationUnit is null");
return null;
}
if (cu.FileName == null || cu.FileName.Length == 0) {
Console.WriteLine("declaringType.CompilationUnit.FileName is empty");
return null;
}
IRegion reg = resolvedMember.Region;
if (reg != null)
return new FilePosition(cu.FileName, new Point(reg.BeginLine, reg.BeginColumn));
else
return new FilePosition(cu.FileName, Point.Empty);
}
}
#endregion

36
src/Main/Base/Project/Src/TextEditor/Actions.cs

@ -16,6 +16,7 @@ using ICSharpCode.TextEditor.Actions; @@ -16,6 +16,7 @@ using ICSharpCode.TextEditor.Actions;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Dom;
namespace ICSharpCode.SharpDevelop.DefaultEditor.Actions
{
@ -41,4 +42,39 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Actions @@ -41,4 +42,39 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Actions
sdtac.CreateCodeCompletionDataProvider(true), '\0');
}
}
public class GoToDefinition : AbstractEditAction
{
public override void Execute(TextArea textArea)
{
TextEditorControl textEditorControl = textArea.MotherTextEditorControl;
IDocument document = textEditorControl.Document;
string textContent = document.TextContent;
int caretLineNumber = document.GetLineNumberForOffset(textEditorControl.ActiveTextAreaControl.Caret.Offset) + 1;
int caretColumn = textEditorControl.ActiveTextAreaControl.Caret.Offset - document.GetLineSegment(caretLineNumber - 1).Offset + 1;
IExpressionFinder expressionFinder = ParserService.GetExpressionFinder(textEditorControl.FileName);
if (expressionFinder == null)
return;
string expression = expressionFinder.FindFullExpression(textContent, textEditorControl.ActiveTextAreaControl.Caret.Offset);
if (expression == null || expression.Length == 0)
return;
ResolveResult result = ParserService.Resolve(expression, caretLineNumber, caretColumn, textEditorControl.FileName, textContent);
if (result != null) {
FilePosition pos = result.GetDefinitionPosition();
if (pos != null) {
try {
if (pos.Position.IsEmpty)
FileService.OpenFile(pos.Filename);
else
FileService.JumpToFilePosition(pos.Filename, pos.Position.X - 1, pos.Position.Y - 1);
} catch (Exception ex) {
Console.WriteLine("Error jumping to '" + pos.Filename + "':\n" + ex.ToString());
MessageBox.Show("Error jumping to '" + pos.Filename + "':\n" + ex.ToString());
}
}
}
}
}
}

32
src/Main/Base/Project/Src/TextEditor/Commands/NavigationCommands.cs

@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version value="$version"/>
// </file>
using System;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Actions;
namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
{
public class GoToDefinition : AbstractEditActionMenuCommand
{
public override IEditAction EditAction {
get {
// TODO: use click position instead of cursor position
return new ICSharpCode.SharpDevelop.DefaultEditor.Actions.GoToDefinition();
}
}
}
/*
IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
if (window == null || !(window.ViewContent is ITextEditorControlProvider)) {
return;
}
TextEditorControl textEditorControl = ((ITextEditorControlProvider)window.ViewContent).TextEditorControl;
*/
}

5
src/Main/Base/Test/ICSharpCode.SharpDevelop.Tests.csproj

@ -13,11 +13,6 @@ @@ -13,11 +13,6 @@
<NoConfig>False</NoConfig>
<RunPostBuildEvent>OnSuccessfulBuild</RunPostBuildEvent>
<OutputType>Library</OutputType>
<StartupObject />
<ApplicationIcon />
<Win32Resource />
<AssemblyOriginatorKeyFile />
<AssemblyKeyProviderName />
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

26
src/Main/Base/Test/NRefactoryResolverTests.cs

@ -237,5 +237,31 @@ interface IInterface2 { @@ -237,5 +237,31 @@ interface IInterface2 {
}
Assert.Fail("Method2 not found");
}
[Test]
public void InvalidMethodCallTest()
{
string program = @"class A {
void Method(string b) {
}
}
";
ResolveResult result = Resolve(program, "b.ThisMethodDoesNotExistOnString()", 3, 24);
Assert.IsNull(result, "result");
}
[Test]
public void InvalidConstructorCallTest()
{
string program = @"class A {
void Method() {
}
}
";
ResolveResult result = Resolve(program, "new ThisClassDoesNotExist()", 3, 24);
Assert.IsNull(result, "result");
}
}
}

6
src/Main/Core/Project/ICSharpCode.Core.csproj

@ -18,7 +18,8 @@ @@ -18,7 +18,8 @@
<DebugSymbols>True</DebugSymbols>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<OutputPath>..\..\..\..\bin\</OutputPath>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>False</DebugSymbols>
@ -26,7 +27,8 @@ @@ -26,7 +27,8 @@
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<OutputPath>..\..\..\..\bin\</OutputPath>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />

Loading…
Cancel
Save