diff --git a/src/apps/debugger/Jamfile b/src/apps/debugger/Jamfile index 15787aea26..f750787c84 100644 --- a/src/apps/debugger/Jamfile +++ b/src/apps/debugger/Jamfile @@ -168,6 +168,7 @@ Application Debugger : FileSourceCode.cpp Image.cpp ImageInfo.cpp + LineDataSource.cpp ReturnValueInfo.cpp SemaphoreInfo.cpp SourceCode.cpp diff --git a/src/apps/debugger/model/DisassembledCode.h b/src/apps/debugger/model/DisassembledCode.h index d1a9dd7357..8ed734631c 100644 --- a/src/apps/debugger/model/DisassembledCode.h +++ b/src/apps/debugger/model/DisassembledCode.h @@ -25,10 +25,6 @@ public: virtual SourceLanguage* GetSourceLanguage() const; - virtual int32 CountLines() const; - virtual const char* LineAt(int32 index) const; - virtual int32 LineLengthAt(int32 index) const; - virtual bool GetStatementLocationRange( const SourceLocation& location, SourceLocation& _start, @@ -41,6 +37,11 @@ public: const SourceLocation& location) const; TargetAddressRange StatementAddressRange() const; + // LineDataSource + virtual int32 CountLines() const; + virtual const char* LineAt(int32 index) const; + virtual int32 LineLengthAt(int32 index) const; + public: bool AddCommentLine(const BString& line); bool AddInstructionLine(const BString& line, diff --git a/src/apps/debugger/model/FileSourceCode.h b/src/apps/debugger/model/FileSourceCode.h index b30415b9d0..42f661081b 100644 --- a/src/apps/debugger/model/FileSourceCode.h +++ b/src/apps/debugger/model/FileSourceCode.h @@ -33,10 +33,6 @@ public: virtual SourceLanguage* GetSourceLanguage() const; - virtual int32 CountLines() const; - virtual const char* LineAt(int32 index) const; - virtual int32 LineLengthAt(int32 index) const; - virtual bool GetStatementLocationRange( const SourceLocation& location, SourceLocation& _start, @@ -44,6 +40,11 @@ public: virtual LocatableFile* GetSourceFile() const; + // LineDataSource + virtual int32 CountLines() const; + virtual const char* LineAt(int32 index) const; + virtual int32 LineLengthAt(int32 index) const; + private: int32 _FindSourceLocationIndex( const SourceLocation& location, diff --git a/src/apps/debugger/model/LineDataSource.cpp b/src/apps/debugger/model/LineDataSource.cpp new file mode 100644 index 0000000000..ba09e841ea --- /dev/null +++ b/src/apps/debugger/model/LineDataSource.cpp @@ -0,0 +1,12 @@ +/* + * Copyright 2014, Rene Gollent, rene@gollent.com. + * Distributed under the terms of the MIT License. + */ + + +#include "LineDataSource.h" + + +LineDataSource::~LineDataSource() +{ +} diff --git a/src/apps/debugger/model/LineDataSource.h b/src/apps/debugger/model/LineDataSource.h new file mode 100644 index 0000000000..800a0e255b --- /dev/null +++ b/src/apps/debugger/model/LineDataSource.h @@ -0,0 +1,22 @@ +/* + * Copyright 2014, Rene Gollent, rene@gollent.com. + * Distributed under the terms of the MIT License. + */ +#ifndef LINE_DATA_SOURCE_H +#define LINE_DATA_SOURCE_H + + +#include + + +class LineDataSource : public BReferenceable { +public: + virtual ~LineDataSource(); + + virtual int32 CountLines() const = 0; + virtual const char* LineAt(int32 index) const = 0; + virtual int32 LineLengthAt(int32 index) const = 0; +}; + + +#endif // LINE_DATA_SOURCE_H diff --git a/src/apps/debugger/model/SourceCode.h b/src/apps/debugger/model/SourceCode.h index 89610d5c6d..4648032812 100644 --- a/src/apps/debugger/model/SourceCode.h +++ b/src/apps/debugger/model/SourceCode.h @@ -8,6 +8,7 @@ #include +#include "LineDataSource.h" #include "TargetAddressRange.h" @@ -17,7 +18,7 @@ class SourceLocation; class Statement; -class SourceCode : public BReferenceable { +class SourceCode : public LineDataSource { public: virtual ~SourceCode(); @@ -28,10 +29,6 @@ public: virtual SourceLanguage* GetSourceLanguage() const = 0; - virtual int32 CountLines() const = 0; - virtual const char* LineAt(int32 index) const = 0; - virtual int32 LineLengthAt(int32 index) const = 0; - virtual bool GetStatementLocationRange( const SourceLocation& location, SourceLocation& _start, diff --git a/src/apps/debugger/source_language/SyntaxHighlighter.cpp b/src/apps/debugger/source_language/SyntaxHighlighter.cpp index 52fbacb417..68cc1cf574 100644 --- a/src/apps/debugger/source_language/SyntaxHighlighter.cpp +++ b/src/apps/debugger/source_language/SyntaxHighlighter.cpp @@ -7,14 +7,6 @@ #include "SyntaxHighlighter.h" -// #pragma mark - SyntaxHighlightSource - - -SyntaxHighlightSource::~SyntaxHighlightSource() -{ -} - - // #pragma mark - SyntaxHighlightInfo diff --git a/src/apps/debugger/source_language/SyntaxHighlighter.h b/src/apps/debugger/source_language/SyntaxHighlighter.h index 640212b8c7..7a72a363ce 100644 --- a/src/apps/debugger/source_language/SyntaxHighlighter.h +++ b/src/apps/debugger/source_language/SyntaxHighlighter.h @@ -1,4 +1,5 @@ /* + * Copyright 2014, Rene Gollent, rene@gollent.com. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -11,23 +12,24 @@ #include +class LineDataSource; + + enum syntax_highlight_type { - SYNTAX_HIGHLIGHT_NONE, - SYNTAX_HIGHLIGHT_KEYWORD - // TODO:... -}; - - -class SyntaxHighlightSource : public BReferenceable { - virtual ~SyntaxHighlightSource(); - - virtual int32 CountLines() const = 0; - virtual void GetLineAt(int32 index, BString& _line) const - = 0; + SYNTAX_HIGHLIGHT_NONE = 0, + SYNTAX_HIGHLIGHT_KEYWORD, + SYNTAX_HIGHLIGHT_PREPROCESSOR_KEYWORD, + SYNTAX_HIGHLIGHT_IDENTIFIER, + SYNTAX_HIGHLIGHT_OPERATOR, + SYNTAX_HIGHLIGHT_TYPE, + SYNTAX_HIGHLIGHT_NUMERIC_LITERAL, + SYNTAX_HIGHLIGHT_STRING_LITERAL, + SYNTAX_HIGHLIGHT_COMMENT }; class SyntaxHighlightInfo { +public: virtual ~SyntaxHighlightInfo(); virtual int32 GetLineHighlightRanges(int32 line, @@ -45,7 +47,7 @@ class SyntaxHighlighter : public BReferenceable { public: virtual ~SyntaxHighlighter(); - virtual status_t ParseText(SyntaxHighlightSource* source, + virtual status_t ParseText(LineDataSource* source, SyntaxHighlightInfo*& _info) = 0; // caller owns the returned info };