Skip to content
Permalink
Browse files

Basic bug-marking form.

  • Loading branch information...
Daniel W. Barowy
Daniel W. Barowy committed Oct 17, 2016
1 parent 174acd4 commit 8c3c5aee04755cb612655d6d82ca631fe77b035d
@@ -0,0 +1,29 @@
namespace ExceLint
type BugKind =
| NotABug
| ReferenceBug
| ReferenceBugInverse
| ConstantWhereFormulaExpected
static member ToKind(kindstr: string) =
match kindstr with
| "no" -> NotABug
| "ref" -> ReferenceBug
| "refi" -> ReferenceBugInverse
| "cwfe" -> ConstantWhereFormulaExpected
| _ -> failwith ("Unknown bug type '" + kindstr + "'")
override self.ToString() : string =
match self with
| NotABug -> "Not a bug"
| ReferenceBug -> "Reference bug"
| ReferenceBugInverse -> "Reference bug (inverse)"
| ConstantWhereFormulaExpected -> "Constant where formula expected"
member self.ToLog() : string =
match self with
| NotABug -> "no"
| ReferenceBug -> "ref"
| ReferenceBugInverse -> "refi"
| ConstantWhereFormulaExpected -> "cwfe"
static member AllKinds : BugKind[] =
Microsoft.FSharp.Reflection.FSharpType.GetUnionCases typeof<BugKind>
|> Array.map (fun uci -> BugKind.ToKind uci.Name)
static member DefaultKind : BugKind = NotABug
@@ -64,6 +64,7 @@
<Compile Include="ErrorModel.fs" />
<Compile Include="ModelBuilder.fs" />
<None Include="App.config" />
<Compile Include="BugKind.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Depends\Depends\Depends.csproj">
@@ -2,23 +2,13 @@

open System
open System.Collections.Generic
open ExceLint

type Address = string
type Worksheet = string
type Workbook = string
type Path = string

type BugKinds =
| NotABug
| ReferenceBug
| ConstantWhereFormulaExpected
static member ToKind(kindstr: string) =
match kindstr with
| "no" -> NotABug
| "ref" -> ReferenceBug
| "cwfe" -> ConstantWhereFormulaExpected
| _ -> failwith ("Unknown bug type '" + kindstr + "'")

let ExceLintGTToAddress(addrstr: Address)(worksheetname: Worksheet)(workbookname: Workbook)(path: Path) : AST.Address =
// we force the mode to absolute because
// that's how Depends reads them
@@ -34,19 +24,19 @@
type GroundTruth(gtpath: string) =
let raw = CSV.OurGroundTruth.Load(gtpath)

let k = new Dictionary<AST.Address,BugKinds>()
let k = new Dictionary<AST.Address,BugKind>()

do
Seq.iter (fun (row: CSV.OurGroundTruth.Row) ->
let addr = ExceLintGTToAddress row.Addr row.Worksheet row.Workbook row.Path
k.Add(addr, BugKinds.ToKind(row.Bug_kind))
k.Add(addr, BugKind.ToKind(row.Bug_kind))
) raw.Rows

member self.IsABug(addr: AST.Address) = if k.ContainsKey addr then k.[addr] <> BugKinds.NotABug else false
member self.IsABug(addr: AST.Address) = if k.ContainsKey addr then k.[addr] <> BugKind.NotABug else false
member self.TrueRefBugsByWorkbook(workbookname: Workbook) =
new HashSet<AST.Address>(
Seq.filter (fun (pair: KeyValuePair<AST.Address,BugKinds>) ->
Seq.filter (fun (pair: KeyValuePair<AST.Address,BugKind>) ->
pair.Key.WorkbookName = workbookname
) k
|> Seq.map (fun (pair: KeyValuePair<AST.Address,BugKinds>) -> pair.Key)
|> Seq.map (fun (pair: KeyValuePair<AST.Address,BugKind>) -> pair.Key)
)
@@ -188,6 +188,12 @@
<Compile Include="ExceLintRibbon.Designer.cs">
<DependentUpon>ExceLintRibbon.cs</DependentUpon>
</Compile>
<Compile Include="MarkAsBugForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MarkAsBugForm.Designer.cs">
<DependentUpon>MarkAsBugForm.cs</DependentUpon>
</Compile>
<Compile Include="ProgBar.cs">
<SubType>Form</SubType>
</Compile>
@@ -214,6 +220,9 @@
<EmbeddedResource Include="ExceLintRibbon.resx">
<DependentUpon>ExceLintRibbon.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="MarkAsBugForm.resx">
<DependentUpon>MarkAsBugForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ProgBar.resx">
<DependentUpon>ProgBar.cs</DependentUpon>
</EmbeddedResource>

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -0,0 +1,92 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ExceLintUI
{
public struct BugAnnotation
{
public ExceLint.BugKind bugkind;
public string notes;
};

public partial class MarkAsBugForm : Form
{
AST.Address _cell;
Dictionary<AST.Address, BugAnnotation> _ba;
ExceLint.BugKind _selected_kind = ExceLint.BugKind.DefaultKind;
string _notes = "";

ExceLint.BugKind[] _sortedBugKinds = ExceLint.BugKind.AllKinds.OrderBy(bk => bk.ToString()).ToArray();
Dictionary<ExceLint.BugKind, int> bkIndices = new Dictionary<ExceLint.BugKind, int>();

public MarkAsBugForm(AST.Address cell, Dictionary<AST.Address,BugAnnotation> bugAnnotations)
{
_cell = cell;
_ba = bugAnnotations;

// populate combo box
BugKindsCombo.DataSource = _sortedBugKinds;

// get indices
for (int i = 0; i < _sortedBugKinds.Length; i++)
{
bkIndices.Add(_sortedBugKinds[i], i);
}

// if the user has already annotated, then...
if (bugAnnotations.ContainsKey(_cell))
{
var bk = bugAnnotations[_cell].bugkind;
var notes = bugAnnotations[_cell].notes;

// get index
var idx = bkIndices[bk];

// select combo box element
BugKindsCombo.SelectedIndex = idx;

// fill notes
bugNotesTextField.Text = notes;
} else
{
BugKindsCombo.SelectedIndex = bkIndices[ExceLint.BugKind.NotABug];
}

InitializeComponent();
}

public ExceLint.BugKind BugKind
{
get
{
return _selected_kind;
}
}

public string Notes
{
get
{
return _notes;
}
}

private void markButton_Click(object sender, EventArgs e)
{
_selected_kind = _sortedBugKinds[BugKindsCombo.SelectedIndex];
_notes = bugNotesTextField.Text;
}

private void cancelButton_Click(object sender, EventArgs e)
{

}
}
}
Oops, something went wrong.

0 comments on commit 8c3c5ae

Please sign in to comment.
You can’t perform that action at this time.