Skip to content

Commit 3ec4288

Browse files
committed
[test] NFC: Extract out NullEditorConsumer
1 parent 572fc4e commit 3ec4288

File tree

2 files changed

+65
-55
lines changed

2 files changed

+65
-55
lines changed

unittests/SourceKit/SwiftLang/CursorInfoTest.cpp

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#include "NullEditorConsumer.h"
1314
#include "SourceKit/Core/Context.h"
1415
#include "SourceKit/Core/LangSupport.h"
1516
#include "SourceKit/Core/NotificationCenter.h"
@@ -41,61 +42,6 @@ static void *createCancellationToken() {
4142

4243
namespace {
4344

44-
class NullEditorConsumer : public EditorConsumer {
45-
bool needsSemanticInfo() override { return needsSema; }
46-
47-
void handleRequestError(const char *Description) override {
48-
llvm_unreachable("unexpected error");
49-
}
50-
51-
bool syntaxMapEnabled() override { return true; }
52-
53-
void handleSyntaxMap(unsigned Offset, unsigned Length, UIdent Kind) override {
54-
}
55-
56-
void handleSemanticAnnotation(unsigned Offset, unsigned Length, UIdent Kind,
57-
bool isSystem) override {}
58-
59-
bool documentStructureEnabled() override { return false; }
60-
61-
void beginDocumentSubStructure(unsigned Offset, unsigned Length,
62-
UIdent Kind, UIdent AccessLevel,
63-
UIdent SetterAccessLevel,
64-
unsigned NameOffset,
65-
unsigned NameLength,
66-
unsigned BodyOffset,
67-
unsigned BodyLength,
68-
unsigned DocOffset,
69-
unsigned DocLength,
70-
StringRef DisplayName,
71-
StringRef TypeName,
72-
StringRef RuntimeName,
73-
StringRef SelectorName,
74-
ArrayRef<StringRef> InheritedTypes,
75-
ArrayRef<std::tuple<UIdent, unsigned, unsigned>> Attrs) override {
76-
}
77-
78-
void endDocumentSubStructure() override {}
79-
80-
void handleDocumentSubStructureElement(UIdent Kind, unsigned Offset,
81-
unsigned Length) override {}
82-
83-
void recordAffectedRange(unsigned Offset, unsigned Length) override {}
84-
85-
void recordAffectedLineRange(unsigned Line, unsigned Length) override {}
86-
87-
bool diagnosticsEnabled() override { return false; }
88-
89-
void handleDiagnostics(ArrayRef<DiagnosticEntryInfo> DiagInfos,
90-
UIdent DiagStage) override {}
91-
void recordFormattedText(StringRef Text) override {}
92-
93-
void handleSourceText(StringRef Text) override {}
94-
95-
public:
96-
bool needsSema = false;
97-
};
98-
9945
struct TestCursorInfo {
10046
// Empty if no error.
10147
std::string Error;
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "SourceKit/Core/LangSupport.h"
14+
15+
namespace SourceKit {
16+
17+
class NullEditorConsumer : public EditorConsumer {
18+
bool needsSemanticInfo() override { return needsSema; }
19+
20+
void handleRequestError(const char *Description) override {
21+
llvm_unreachable("unexpected error");
22+
}
23+
24+
bool syntaxMapEnabled() override { return true; }
25+
26+
void handleSyntaxMap(unsigned Offset, unsigned Length, UIdent Kind) override {
27+
}
28+
29+
void handleSemanticAnnotation(unsigned Offset, unsigned Length, UIdent Kind,
30+
bool isSystem) override {}
31+
32+
bool documentStructureEnabled() override { return false; }
33+
34+
void beginDocumentSubStructure(
35+
unsigned Offset, unsigned Length, UIdent Kind, UIdent AccessLevel,
36+
UIdent SetterAccessLevel, unsigned NameOffset, unsigned NameLength,
37+
unsigned BodyOffset, unsigned BodyLength, unsigned DocOffset,
38+
unsigned DocLength, StringRef DisplayName, StringRef TypeName,
39+
StringRef RuntimeName, StringRef SelectorName,
40+
ArrayRef<StringRef> InheritedTypes,
41+
ArrayRef<std::tuple<UIdent, unsigned, unsigned>> Attrs) override {}
42+
43+
void endDocumentSubStructure() override {}
44+
45+
void handleDocumentSubStructureElement(UIdent Kind, unsigned Offset,
46+
unsigned Length) override {}
47+
48+
void recordAffectedRange(unsigned Offset, unsigned Length) override {}
49+
50+
void recordAffectedLineRange(unsigned Line, unsigned Length) override {}
51+
52+
bool diagnosticsEnabled() override { return false; }
53+
54+
void handleDiagnostics(ArrayRef<DiagnosticEntryInfo> DiagInfos,
55+
UIdent DiagStage) override {}
56+
void recordFormattedText(StringRef Text) override {}
57+
58+
void handleSourceText(StringRef Text) override {}
59+
60+
public:
61+
bool needsSema = false;
62+
};
63+
64+
} // end namespace SourceKit

0 commit comments

Comments
 (0)