Skip to content

Commit

Permalink
Continued improvements to Intellisense
Browse files Browse the repository at this point in the history
  • Loading branch information
erdomke committed Jul 19, 2020
1 parent c98e632 commit 34cae80
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 36 deletions.
1 change: 1 addition & 0 deletions InnovatorAdmin.Api/IO/InnovatorPackageFolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ private string GetRelativePath(string path)
if (string.IsNullOrEmpty(path)) return _manifestPath;
return Path.Combine(_baseFolder, path);
}

private string EnsureRelativePath(string path)
{
var fullPath = GetRelativePath(path);
Expand Down
2 changes: 1 addition & 1 deletion InnovatorAdmin.Api/Metadata/ArasMetadataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public IEnumerable<ItemReference> CoreMethods
get { return _methods.Where(m => m.IsCore); }
}
/// <summary>
/// Enumerable of methods where core = 1
/// Enumerable of methods
/// </summary>
public IEnumerable<Method> AllMethods
{
Expand Down
4 changes: 2 additions & 2 deletions InnovatorAdmin/AssemblyInfo.Version.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Reflection;

[assembly: AssemblyVersion("19.317.39964")]
[assembly: AssemblyFileVersion("19.317.39964")]
[assembly: AssemblyVersion("20.201.32775")]
[assembly: AssemblyFileVersion("20.201.32775")]
58 changes: 29 additions & 29 deletions InnovatorAdmin/Editor/Aml/CompletionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,31 +266,30 @@ public async Task<CompletionContext> GetCompletions(ITextSource xml, int caret,
case "":
break;
default:
var attributes = new Dictionary<string, string>
var attributes = new List<AmlDocumentation>()
{
{ "action", null }
, { "id", null }
, { "idlist", null }
, { "type", null }
, { "typeId", null }
new AmlDocumentation("action", "AML action to perform", AmlDataType.ItemName, "Method"),
new AmlDocumentation("id", "ID of the context item", AmlDataType.Item, path.LastOrDefault()?.Type),
new AmlDocumentation("idlist", "Comma separated list of IDs", AmlDataType.String),
new AmlDocumentation("type", "Name of the context itemtype", AmlDataType.ItemName, "ItemType"),
new AmlDocumentation("typeId", "ID of the context itemtype", AmlDataType.Item, "ItemType")
};

if (TryGetActionDoc(path, out var doc))
{
foreach (var attr in doc.Attributes)
attributes[attr.Name] = attr.Summary;
}

if (path.Count >= 3
&& path[path.Count - 2].LocalName == "Relationships"
&& path[path.Count - 3].LocalName == "Item"
&& path[path.Count - 3].Action == "GetItemRepeatConfig")
{
attributes["repeatProp"] = null;
attributes["repeatTimes"] = null;
attributes.Add(new AmlDocumentation("repeatProp", "Property to use for recursion", AmlDataType.ItemName, "Property"));
attributes.Add(new AmlDocumentation("repeatTimes", "Number of times to recurse", AmlDataType.Integer));
}

if (TryGetActionDoc(path, out var doc))
{
attributes.AddRange(doc.Attributes);
}

items = Attributes(notExisting, attributes).ToArray();
items = Attributes(notExisting, attributes.GroupBy(a => a.Name).Select(g => g.Last())).ToArray();
foreach (var item in items.OfType<AttributeCompletionData>().Where(i => i.Text == "where"))
{
item.QuoteChar = '"';
Expand All @@ -301,7 +300,7 @@ public async Task<CompletionContext> GetCompletions(ITextSource xml, int caret,
default:
if (TryGetActionDoc(path, out var actionDoc))
{
items = Attributes(notExisting, actionDoc.Attributes.Select(a => new KeyValuePair<string, string>(a.Name, a.Summary))).ToArray();
items = Attributes(notExisting, actionDoc.Attributes).ToArray();
}
else
{
Expand Down Expand Up @@ -488,11 +487,12 @@ public async Task<CompletionContext> GetCompletions(ITextSource xml, int caret,
{
Text = m.KeyedName,
Image = Icons.Method16.Wpf,
Description = m.Documentation?.Summary
Description = Tooltips.Documentation(m.Documentation, "method")
}).Concat(methods.Select(m => (ICompletionData)new AttributeValueCompletionData()
{
Text = m,
Image = Icons.MethodFriend16.Wpf
Image = Icons.MethodFriend16.Wpf,
Description = _actionDocs.TryGetValue(m, out var actionDoc) ? Tooltips.Documentation(actionDoc, "action") : null
}));
break;
case "id":
Expand Down Expand Up @@ -696,7 +696,7 @@ public async Task<CompletionContext> GetCompletions(ITextSource xml, int caret,
.Where(a => a.ValueTypes.All(t => t.Type == AmlDataType.Enum) && a.ValueTypes.Sum(t => t.Values.Count()) == 1)
.Select(a => $" {a.Name}='{a.ValueTypes.SelectMany(t => t.Values).Single()}'")),
Image = Icons.XmlTag16.Wpf,
Description = e.Summary
Description = Tooltips.Documentation(e, "parameter")
};
});
}
Expand Down Expand Up @@ -899,13 +899,13 @@ private static IEnumerable<ICompletionData> Attributes(Func<string, bool> filter
});
}

private static IEnumerable<ICompletionData> Attributes(Func<string, bool> filter, IEnumerable<KeyValuePair<string, string>> values)
private static IEnumerable<ICompletionData> Attributes(Func<string, bool> filter, IEnumerable<AmlDocumentation> values)
{
return values.Where(k => filter(k.Key)).Select(k => (ICompletionData)new AttributeCompletionData()
return values.Where(d => filter(d.Name)).Select(d => (ICompletionData)new AttributeCompletionData()
{
Text = k.Key,
Text = d.Name,
Image = Icons.Field16.Wpf,
Description = k.Value
Description = Tooltips.Documentation(d, "parameter")
});
}

Expand Down Expand Up @@ -1670,19 +1670,19 @@ public CompletionDocumentation(string name, CompletionOverride overrideFunc, Aml

static AmlEditorHelper()
{
_actionDocs["add"] = new AmlDocumentation("add")
_actionDocs["add"] = new AmlDocumentation("add", "Add an item to the database")
.WithAttribute("do_skipOnAfterAdd", "If 1 then don't run onAfterAdd server events. Default is 0", AmlDataType.Boolean)
.WithAttribute("serverEvents", "If 0 then disable server events when running the doGetItem only. onBefore/AfterAdd events are not disabled. Default is 1.", AmlDataType.Boolean);
_actionDocs["AddItem"] = _actionDocs["add"];
_actionDocs["copy"] = new AmlDocumentation("copy")
_actionDocs["copy"] = new AmlDocumentation("copy", "Create a copy of the specified item. Used when copying relationships in the relationships grid")
.WithAttribute("do_add", "Whether or not to add the item to the database", AmlDataType.Boolean)
.WithAttribute("do_lock", "Whether or not to keep the item locked when the operation is complete", AmlDataType.Boolean);
_actionDocs["copyAsIs"] = new AmlDocumentation("copyAsIs")
_actionDocs["copyAsIs"] = new AmlDocumentation("copyAsIs", "Create a copy of the specified item. Used with the `Save As...` menu item")
.WithAttribute("lock_related", null, AmlDataType.Boolean)
.WithAttribute("do_lock", "Whether or not to keep the item locked when the operation is complete", AmlDataType.Boolean)
.WithAttribute("useInputProperties", null, AmlDataType.Boolean);
_actionDocs["copyAsNew"] = _actionDocs["copyAsIs"];
_actionDocs["get"] = new AmlDocumentation("get")
_actionDocs["get"] = new AmlDocumentation("get", "Queries the database to return information about the specified items")
.WithAttribute("select", "A comma-delimited list of property names (column names) to return", AmlDataType.SelectList)
.WithAttribute("orderBy", "A comma-delimited list of property names (column names) specifying the order of the results", AmlDataType.OrderBy)
.WithAttribute("page", "The page number for the results set.", AmlDataType.Integer)
Expand All @@ -1701,7 +1701,7 @@ static AmlEditorHelper()
.WithAttribute("config_path", null, AmlDataType.String)
.WithAttribute("where", null, AmlDataType.WhereClause)
.WithAttribute("returnMode", null, AmlDataType.Enum, "itemsOnly", "countOnly");
_actionDocs["create"] = new AmlDocumentation("create");
_actionDocs["create"] = new AmlDocumentation("create", "Acts as a `get` if the Item exists, otherwise acts as an `add`.");
_actionDocs["create"].WithAttributes(_actionDocs["get"].Attributes);
_actionDocs["create"].WithAttributes(_actionDocs["add"].Attributes);

Expand Down Expand Up @@ -1858,7 +1858,7 @@ static AmlEditorHelper()
, new AmlDocumentation("Comments", null, AmlDataType.String)
, new AmlDocumentation("Complete", null, AmlDataType.Boolean));
_actionDocs["instantiateWorkflow"] = new AmlDocumentation("instantiateWorkflow")
.WithElements(new AmlDocumentation("WorkflowMap", null, AmlDataType.Item, "Workflow Map"));
.WithElements(new AmlDocumentation("WorkflowMap", "The workflow map to instantiate", AmlDataType.Item, "Workflow Map"));
_actionDocs["promoteItem"] = new AmlDocumentation("promoteItem")
.WithElements(new AmlDocumentation("state"),
new AmlDocumentation("comments"));
Expand Down
101 changes: 97 additions & 4 deletions InnovatorAdmin/Editor/Aml/Tooltips.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
Expand All @@ -29,7 +28,7 @@ public static object Property(Property property)
});
block.Inlines.Add(new Run(property.Name)
{
FontWeight = System.Windows.FontWeight.FromOpenTypeWeight(700)
FontWeight = FontWeight.FromOpenTypeWeight(700)
});

if (!string.IsNullOrEmpty(property.Label))
Expand All @@ -56,7 +55,11 @@ public static object Property(Property property)
}

if (property.IsRequired)
builder.Append(", not null");
{
if (builder[builder.Length - 1] != '[')
builder.Append(", ");
builder.Append("not null");
}
builder.Append(']');

block.Inlines.Add(new Run(builder.ToString())
Expand All @@ -69,11 +72,51 @@ public static object Property(Property property)
block.Inlines.Add(new LineBreak());
block.Inlines.Add(new Run(property.Description));
}
else if (_propertyHelp.TryGetValue(property.Name, out var descrip))
{
block.Inlines.Add(new LineBreak());
block.Inlines.Add(new Run(descrip));
}

return block;
});
}

private static Dictionary<string, string> _propertyHelp = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) {
{ "classification", "Describes the type of the item with a tree-like structure (Inherited from Item)" },
{ "config_id", "Server assigned. Defines a common ID linking all the generations of an item (Inherited from Item)" },
{ "created_by_id", "Server assigned. ID of the user that created the item (Inherited from Item)" },
{ "created_on", "Server assigned. Date the item was created (Inherited from Item)" },
{ "css", "Defines styling within the web client (Inherited from Item)" },
{ "current_state", "Server assigned. ID of the current life cycle state (Inherited from Item)" },
{ "generation", "Server assigned. Sequential number identifying the version/snapshot of the item (Inherited from Item)" },
{ "id", "Server assigned. A 32 character globally unique identifier (GUID) for the item (Inherited from Item)" },
{ "is_current", "Server assigned. Boolean returning true if this is the most current generation (Inherited from Item)" },
{ "is_released", "Boolean returning true if this item is in a released life cycle state (Inherited from Item)" },
{ "keyed_name", "Server assigned. Human friendly identifier for the item (Inherited from Item)" },
{ "locked_by_id", "ID of the user that has locked the item (Inherited from Item)" },
{ "major_rev", "Revision label of the versioned item (Inherited from Item)" },
{ "managed_by_id", "ID of the identity considered the 'Manager' for permissions and workflow assignments (Inherited from Item)" },
{ "minor_rev", "Not used (Inherited from Item)" },
{ "modified_by_id", "Server assigned. ID of the user that last modified the item (Inherited from Item)" },
{ "modified_on", "Server assigned. Date the item was last modified (Inherited from Item)" },
{ "new_version", "Boolean returning true if a new version of this automatically versioned item has been created for the current lock-save-unlock cycle (Inherited from Item)" },
{ "not_lockable", "Boolean returning true if this item cannot be changed regardless of permissions (Inherited from Item)" },
{ "owned_by_id", "ID of the identity considered the 'Owner' for permissions and workflow assignments (Inherited from Item)" },
{ "permission_id", "ID of the current permission item (Inherited from Item)" },
{ "state", "Server assigned. Name of the current life cycle state (Inherited from Item)" },
{ "team_id", "ID of the current team (Inherited from Item)" },
{ "effective_date", "Date that this version is considered effective and can first be used (Inherited from Versioned Item)" },
{ "release_date", "Server assigned. Date that this version was first promoted to a released life cycle state (Inherited from Versioned Item)" },
{ "superseded_date", "Date that this version was superseded by the release of a more recent version (Inherited from Versioned Item)" },
{ "behavior", "Server assigned. Describes whether the related item will always point to the specified version or the most current version (Inherited from Relationship)" },
{ "source_id", "ID of the parent (source) item for the relationship (Inherited from Relationship)" },
{ "related_id", "ID of the child (related) item for the relationship (Inherited from Relationship)" },
{ "sort_order", "Number describing the order items should be sorted (Inherited from Relationship)" },
{ "indexed_on", "Server assigned. Date the item was last indexed by the Enterprise Search indexer (Inherited from Indexed Item)" },
{ "itemtype", "ID of the item type this item belongs to (Inherited from Poly Item)" }
};

public static object ItemType(ItemType itemType)
{
if (itemType == null)
Expand All @@ -96,7 +139,7 @@ public static object ItemType(ItemType itemType)
});
block.Inlines.Add(new Run(itemType.Name)
{
FontWeight = System.Windows.FontWeight.FromOpenTypeWeight(700)
FontWeight = FontWeight.FromOpenTypeWeight(700)
});

if (!string.IsNullOrEmpty(itemType.Label ?? itemType.TabLabel))
Expand All @@ -120,5 +163,55 @@ public static object ItemType(ItemType itemType)
return block;
});
}

public static object Documentation(AmlDocumentation documentation, string type)
{
if (documentation == null)
return null;

return FormatText.Invoke(() =>
{
var block = new TextBlock()
{
TextWrapping = TextWrapping.Wrap
};
block.Inlines.Add(new Run(type + " ")
{
Foreground = Brushes.Gray
});
block.Inlines.Add(new Run(documentation.Name)
{
FontWeight = FontWeight.FromOpenTypeWeight(700)
});

if (documentation.ValueTypes.Any(t => t.Type != AmlDataType.Unknown))
{
block.Inlines.Add(new Run(": "));
block.Inlines.Add(new Run(string.Join("|", documentation.ValueTypes
.Where(t => t.Type != AmlDataType.Unknown)
.Select(v =>
{
var typeString = v.Type.ToString();
typeString = typeString.Substring(0, 1).ToLowerInvariant() + typeString.Substring(1);
if (!string.IsNullOrEmpty(v.Source))
typeString += "[" + v.Source + "]";
else if (v.Values.Any())
typeString += "[" + string.Join("|", v.Values) + "]";
return typeString;
})))
{
Foreground = Brushes.Blue
});
}

if (!string.IsNullOrEmpty(documentation.Summary))
{
block.Inlines.Add(new LineBreak());
block.Inlines.Add(new Run(documentation.Summary));
}

return block;
});
}
}
}
1 change: 1 addition & 0 deletions InnovatorAdmin/InnovatorAdmin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@
</Compile>
<Compile Include="Editor\Aml\EditorItemData.cs" />
<Compile Include="Editor\Aml\ScriptMenuGenerator.cs" />
<Compile Include="Editor\Aml\Tooltips.cs" />
<Compile Include="Editor\CompletionData\CompletionList.cs" />
<Compile Include="Editor\CompletionData\CompletionListBox.cs" />
<Compile Include="Editor\CompletionData\CompletionWindow.cs" />
Expand Down

0 comments on commit 34cae80

Please sign in to comment.