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:
Rene Gollent 2014-11-24 22:37:59 -05:00
parent d5ef985e18
commit d431ff418f
8 changed files with 62 additions and 34 deletions

View File

@ -168,6 +168,7 @@ Application Debugger :
FileSourceCode.cpp
Image.cpp
ImageInfo.cpp
LineDataSource.cpp
ReturnValueInfo.cpp
SemaphoreInfo.cpp
SourceCode.cpp

View File

@ -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,

View File

@ -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,

View 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()
{
}

View 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

View File

@ -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,

View File

@ -7,14 +7,6 @@
#include "SyntaxHighlighter.h"
// #pragma mark - SyntaxHighlightSource
SyntaxHighlightSource::~SyntaxHighlightSource()
{
}
// #pragma mark - SyntaxHighlightInfo

View File

@ -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
};