mirror of https://gitlab.com/basile.b/dexed.git
use common type widget / cesyms libdprase line nbr
This commit is contained in:
parent
83087766bf
commit
28b29e7b74
|
|
@ -91,7 +91,8 @@ enum SymbolType
|
||||||
{
|
{
|
||||||
_alias,
|
_alias,
|
||||||
_class,
|
_class,
|
||||||
_enum,
|
_enum,
|
||||||
|
_error,
|
||||||
_function,
|
_function,
|
||||||
_interface,
|
_interface,
|
||||||
_import,
|
_import,
|
||||||
|
|
@ -100,14 +101,13 @@ enum SymbolType
|
||||||
_template,
|
_template,
|
||||||
_union,
|
_union,
|
||||||
_variable,
|
_variable,
|
||||||
_error,
|
|
||||||
_warning
|
_warning
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Symbol
|
struct Symbol
|
||||||
{
|
{
|
||||||
int line;
|
size_t line;
|
||||||
int col;
|
size_t col;
|
||||||
string name;
|
string name;
|
||||||
SymbolType type;
|
SymbolType type;
|
||||||
Symbol * [] subs;
|
Symbol * [] subs;
|
||||||
|
|
@ -162,8 +162,8 @@ class SymbolListBuilder : ASTVisitor
|
||||||
static void astError(string fname, size_t line, size_t col, string msg, bool isErr)
|
static void astError(string fname, size_t line, size_t col, string msg, bool isErr)
|
||||||
{
|
{
|
||||||
Symbol * newSym = construct!Symbol;
|
Symbol * newSym = construct!Symbol;
|
||||||
newSym.col = cast(int) col;
|
newSym.col = col;
|
||||||
newSym.line = cast(int) line;
|
newSym.line = line;
|
||||||
newSym.name = msg;
|
newSym.name = msg;
|
||||||
isErr ? newSym.type = SymbolType._error : newSym.type = SymbolType._warning;
|
isErr ? newSym.type = SymbolType._error : newSym.type = SymbolType._warning;
|
||||||
illFormed ~= newSym;
|
illFormed ~= newSym;
|
||||||
|
|
@ -205,13 +205,13 @@ class SymbolListBuilder : ASTVisitor
|
||||||
count++;
|
count++;
|
||||||
auto result = construct!Symbol;
|
auto result = construct!Symbol;
|
||||||
result.name = adt.name.text;
|
result.name = adt.name.text;
|
||||||
result.line = cast(int) adt.name.line;
|
result.line = adt.name.line;
|
||||||
result.col = cast(int) adt.name.column;
|
result.col = adt.name.column;
|
||||||
parent.subs ~= result;
|
parent.subs ~= result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(0, "addDeclaration no implemented for " ~ DT.stringof);
|
version(none) assert(0, "addDeclaration no implemented for " ~ DT.stringof);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// visitor implementation if the declarator is based on a Token named "name".
|
/// visitor implementation if the declarator is based on a Token named "name".
|
||||||
|
|
@ -235,15 +235,14 @@ class SymbolListBuilder : ASTVisitor
|
||||||
count++;
|
count++;
|
||||||
auto result = construct!Symbol;
|
auto result = construct!Symbol;
|
||||||
result.name = name;
|
result.name = name;
|
||||||
result.line = cast(int) line;
|
result.line = line;
|
||||||
result.col = cast(int) col;
|
result.col = col;
|
||||||
result.type = st;
|
result.type = st;
|
||||||
parent.subs ~= result;
|
parent.subs ~= result;
|
||||||
}
|
}
|
||||||
|
|
||||||
final override void visit(const AliasDeclaration decl)
|
final override void visit(const AliasDeclaration decl)
|
||||||
{
|
{
|
||||||
// old alias syntax not supported by this method
|
|
||||||
// why is initializers an array ?
|
// why is initializers an array ?
|
||||||
if (decl.initializers.length > 0)
|
if (decl.initializers.length > 0)
|
||||||
namedVisitorImpl!(AliasInitializer, SymbolType._alias)(decl.initializers[0]);
|
namedVisitorImpl!(AliasInitializer, SymbolType._alias)(decl.initializers[0]);
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ type
|
||||||
_alias,
|
_alias,
|
||||||
_class,
|
_class,
|
||||||
_enum,
|
_enum,
|
||||||
|
_error,
|
||||||
_function,
|
_function,
|
||||||
_interface,
|
_interface,
|
||||||
_import,
|
_import,
|
||||||
|
|
@ -24,7 +25,6 @@ type
|
||||||
_template,
|
_template,
|
||||||
_union,
|
_union,
|
||||||
_variable,
|
_variable,
|
||||||
_error,
|
|
||||||
_warning
|
_warning
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -33,14 +33,14 @@ type
|
||||||
// Encapsulates a symbol to enable structured serialization
|
// Encapsulates a symbol to enable structured serialization
|
||||||
TSymbol = class(TCollectionItem)
|
TSymbol = class(TCollectionItem)
|
||||||
private
|
private
|
||||||
fline, fCol: integer;
|
fline, fCol: nativeUint;
|
||||||
fName: string;
|
fName: string;
|
||||||
fType: TSymbolType;
|
fType: TSymbolType;
|
||||||
fSubs: TSymbolCollection;
|
fSubs: TSymbolCollection;
|
||||||
procedure setSubs(aValue: TSymbolCollection);
|
procedure setSubs(aValue: TSymbolCollection);
|
||||||
published
|
published
|
||||||
property line: Integer read fline write fLine;
|
property line: nativeUint read fline write fLine;
|
||||||
property col: Integer read fCol write fCol;
|
property col: nativeUint read fCol write fCol;
|
||||||
property name: string read fName write fName;
|
property name: string read fName write fName;
|
||||||
property symType: TSymbolType read fType write fType;
|
property symType: TSymbolType read fType write fType;
|
||||||
property subs: TSymbolCollection read fSubs write setSubs;
|
property subs: TSymbolCollection read fSubs write setSubs;
|
||||||
|
|
@ -49,7 +49,7 @@ type
|
||||||
destructor destroy; override;
|
destructor destroy; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Encapsulates a ssymbol ub symbols.
|
// Encapsulates a the sub symbols.
|
||||||
TSymbolCollection = class(TCollection)
|
TSymbolCollection = class(TCollection)
|
||||||
private
|
private
|
||||||
function getSub(index: Integer): TSymbol;
|
function getSub(index: Integer): TSymbol;
|
||||||
|
|
@ -58,7 +58,7 @@ type
|
||||||
property sub[index: Integer]: TSymbol read getSub; default;
|
property sub[index: Integer]: TSymbol read getSub; default;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Serializable Symbol list
|
// Serializable symbol list
|
||||||
TSymbolList = class(TComponent)
|
TSymbolList = class(TComponent)
|
||||||
private
|
private
|
||||||
fSymbols: TSymbolCollection;
|
fSymbols: TSymbolCollection;
|
||||||
|
|
@ -522,7 +522,7 @@ end;
|
||||||
procedure TCESymbolListWidget.TreeDeletion(Sender: TObject; Node: TTreeNode);
|
procedure TCESymbolListWidget.TreeDeletion(Sender: TObject; Node: TTreeNode);
|
||||||
begin
|
begin
|
||||||
if (node.Data <> nil) then
|
if (node.Data <> nil) then
|
||||||
Dispose(PInt64(node.Data));
|
Dispose(PNativeUint(node.Data));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCESymbolListWidget.btnRefreshClick(Sender: TObject);
|
procedure TCESymbolListWidget.btnRefreshClick(Sender: TObject);
|
||||||
|
|
@ -615,13 +615,13 @@ end;
|
||||||
|
|
||||||
procedure TCESymbolListWidget.TreeDblClick(Sender: TObject);
|
procedure TCESymbolListWidget.TreeDblClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
line: Int64;
|
line: NativeUint;
|
||||||
begin
|
begin
|
||||||
if fDoc = nil then exit;
|
if fDoc = nil then exit;
|
||||||
if Tree.Selected = nil then exit;
|
if Tree.Selected = nil then exit;
|
||||||
if Tree.Selected.Data = nil then exit;
|
if Tree.Selected.Data = nil then exit;
|
||||||
//
|
//
|
||||||
line := PInt64(Tree.Selected.Data)^;
|
line := PNativeUInt(Tree.Selected.Data)^;
|
||||||
fDoc.CaretY := line;
|
fDoc.CaretY := line;
|
||||||
fDoc.SelectLine;
|
fDoc.SelectLine;
|
||||||
end;
|
end;
|
||||||
|
|
@ -684,31 +684,31 @@ begin
|
||||||
_warning : exit(ndWarn);
|
_warning : exit(ndWarn);
|
||||||
_error : exit(ndErr);
|
_error : exit(ndErr);
|
||||||
end else case stype of
|
end else case stype of
|
||||||
_alias: exit(newCat('Alias'));
|
_alias: exit(newCat('Alias'));
|
||||||
_class: exit(newCat('Class'));
|
_class: exit(newCat('Class'));
|
||||||
_enum: exit(newCat('Enum'));
|
_enum: exit(newCat('Enum'));
|
||||||
_function: exit(newCat('Function'));
|
_function: exit(newCat('Function'));
|
||||||
_import: exit(newCat('Import'));
|
_import: exit(newCat('Import'));
|
||||||
_interface: exit(newCat('Interface'));
|
_interface: exit(newCat('Interface'));
|
||||||
_mixin: exit(newCat('Mixin'));
|
_mixin: exit(newCat('Mixin'));
|
||||||
_struct: exit(newCat('Struct'));
|
_struct: exit(newCat('Struct'));
|
||||||
_template: exit(newCat('Template'));
|
_template: exit(newCat('Template'));
|
||||||
_union: exit(newCat('Union'));
|
_union: exit(newCat('Union'));
|
||||||
_variable: exit(newCat('Variable'));
|
_variable: exit(newCat('Variable'));
|
||||||
_warning: exit(ndWarn);
|
_warning: exit(ndWarn);
|
||||||
_error: exit(ndErr);
|
_error: exit(ndErr);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
//
|
//
|
||||||
procedure symbolToTreeNode(origin: TTreenode; sym: TSymbol);
|
procedure symbolToTreeNode(origin: TTreenode; sym: TSymbol);
|
||||||
var
|
var
|
||||||
data: PInt64;
|
data: PNativeUint;
|
||||||
cat: TTreeNode;
|
cat: TTreeNode;
|
||||||
node: TTreeNode;
|
node: TTreeNode;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
cat := getCatNode(origin, sym.symType);
|
cat := getCatNode(origin, sym.symType);
|
||||||
data := new(PInt64);
|
data := new(PNativeUint);
|
||||||
data^ := sym.fline;
|
data^ := sym.fline;
|
||||||
node := tree.Items.AddChildObject(cat, sym.name, data);
|
node := tree.Items.AddChildObject(cat, sym.name, data);
|
||||||
if not fShowChildCategories then node := nil;
|
if not fShowChildCategories then node := nil;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue