Debugger: Cleanups/adjustments to syntax interfaces.
- Add missing public keyword for SyntaxHighlightSource/SyntaxHighlightInfo. - Add initial set of basic syntax highlight types. - Remove SyntaxHighlightSource. Instead, add a general purpose LineDataSource interface to the model classes. Correspondingly adjust SourceCode to inherit from it and fixup its derivatives accordingly; also adjust SyntaxHighlighter to take a LineDataSource rather than a SyntaxHighlightSource.
This commit is contained in:
parent
d5ef985e18
commit
d431ff418f
@ -168,6 +168,7 @@ Application Debugger :
|
||||
FileSourceCode.cpp
|
||||
Image.cpp
|
||||
ImageInfo.cpp
|
||||
LineDataSource.cpp
|
||||
ReturnValueInfo.cpp
|
||||
SemaphoreInfo.cpp
|
||||
SourceCode.cpp
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
12
src/apps/debugger/model/LineDataSource.cpp
Normal file
12
src/apps/debugger/model/LineDataSource.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright 2014, Rene Gollent, rene@gollent.com.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "LineDataSource.h"
|
||||
|
||||
|
||||
LineDataSource::~LineDataSource()
|
||||
{
|
||||
}
|
22
src/apps/debugger/model/LineDataSource.h
Normal file
22
src/apps/debugger/model/LineDataSource.h
Normal file
@ -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 <Referenceable.h>
|
||||
|
||||
|
||||
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
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include <Referenceable.h>
|
||||
|
||||
#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,
|
||||
|
@ -7,14 +7,6 @@
|
||||
#include "SyntaxHighlighter.h"
|
||||
|
||||
|
||||
// #pragma mark - SyntaxHighlightSource
|
||||
|
||||
|
||||
SyntaxHighlightSource::~SyntaxHighlightSource()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - SyntaxHighlightInfo
|
||||
|
||||
|
||||
|
@ -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 <Referenceable.h>
|
||||
|
||||
|
||||
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
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user