private static void NavigateToFunction(FunctionImport fi) { if (fi != null && fi.FunctionImportMapping != null) { Debug.Assert(fi.FunctionImportMapping.FunctionImportName != null, "FunctionImportName is null"); if (fi.FunctionImportMapping.FunctionImportName != null) { ExplorerNavigationHelper.NavigateTo(fi.FunctionImportMapping.FunctionImportName.Target); } } }
private static void EscherDesignerNavigate(IServiceProvider serviceProvider, Uri uri, ErrorTask task) { // // Try to open the document in Escher. If the designer is already open, then this call will only activate the // frame; it might fire a selection change event but it will not reload the artifact. // // Do this first so if there is any problem in the code below with out-of-date line numbers, the document will open // if it is closed, and the error list will be refreshed with correct line-numbers. // IVsUIHierarchy ppHierOpen; uint itemID; IVsWindowFrame windowFrame; // Check if there is already primary or logical view opened for the document. // If not, open the primary view for the document. if ( !VsShellUtilities.IsDocumentOpen( serviceProvider, uri.LocalPath, VSConstants.LOGVIEWID_Primary, out ppHierOpen, out itemID, out windowFrame) && !VsShellUtilities.IsDocumentOpen( serviceProvider, uri.LocalPath, PackageConstants.guidLogicalView, out ppHierOpen, out itemID, out windowFrame)) { VsShellUtilities.OpenDocumentWithSpecificEditor( serviceProvider, uri.LocalPath, PackageConstants.guidEscherEditorFactory, VSConstants.LOGVIEWID_Primary); } // sanity check. If this is null, something bad happened with loading our package if (_dslDesignerOnNavigate == null) { Debug.Fail("_dslDesignerOnNavigate is null!"); return; } // get the artifact from the model manager var artifact = PackageManager.Package.ModelManager.GetArtifact(uri); if (artifact == null) { Debug.Fail( "We determined the artifact was designer-safe and we tried to open it in the designer, but where is the artifact?"); return; } var xobject = artifact.FindXObjectForLineAndColumn(task.Line, task.Column); Debug.Assert( xobject != null, "couldn't get XObject for artifact " + uri + ", line " + task.Line + ", column " + task.Column); var efobject = ModelItemAnnotation.GetModelItem(xobject); // we got the root xobject node, so fix this up. if (efobject == null) { efobject = artifact; Debug.Assert( task.Line <= 0 && task.Column <= 0, "non-zero line/column didn't find an efobject linked to an xobject!"); } var cModel = efobject.GetParentOfType(typeof(ConceptualEntityModel)) as ConceptualEntityModel; var sModel = efobject.GetParentOfType(typeof(StorageEntityModel)) as StorageEntityModel; var mModel = efobject.GetParentOfType(typeof(MappingModel)) as MappingModel; if (cModel != null) { var isComplexTypeOrFunctionImportOrChild = false; var obj = efobject; while (obj != null) { if (obj is ComplexType || obj is FunctionImport) { isComplexTypeOrFunctionImportOrChild = true; } obj = obj.Parent; } // node was in c-space, so navigate to appropriate node in the explorer and the designer ExplorerNavigationHelper.NavigateTo(efobject); if (_dslDesignerOnNavigate != null && !isComplexTypeOrFunctionImportOrChild) { _dslDesignerOnNavigate(efobject); } } else if (sModel != null) { // node is in s-space, so navigate to the appropriate node in the explorer. ExplorerNavigationHelper.NavigateTo(efobject); } else if (mModel != null) { // see if this is a function import error var fim = efobject.GetParentOfType(typeof(FunctionImportMapping)) as FunctionImportMapping; if (fim != null) { ExplorerNavigationHelper.NavigateTo(fim.FunctionImportName.Target); } else { // node was in m-space, so navigate to mapped c-space node, and show the mapping editor. // show this first, so the node in the entity-designer will be highlighted. PackageManager.Package.MappingDetailsWindow.Show(); if (_dslDesignerOnNavigate != null) { _dslDesignerOnNavigate(efobject); } } } }