Skip to content

Commit afb7518

Browse files
committed
removed bridge for Latte
1 parent 8e7d034 commit afb7518

File tree

1 file changed

+1
-73
lines changed

1 file changed

+1
-73
lines changed

src/Bridges/Nette/Bridge.php

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -9,97 +9,25 @@
99

1010
namespace Tracy\Bridges\Nette;
1111

12-
use Latte;
1312
use Nette;
1413
use Tracy;
1514
use Tracy\BlueScreen;
1615
use Tracy\Helpers;
1716

1817

1918
/**
20-
* Bridge for NEON & Latte.
19+
* Bridge for NEON.
2120
*/
2221
class Bridge
2322
{
2423
public static function initialize(): void
2524
{
2625
$blueScreen = Tracy\Debugger::getBlueScreen();
27-
if (!class_exists(Latte\Bridges\Tracy\BlueScreenPanel::class)) {
28-
$blueScreen->addPanel([self::class, 'renderLatteError']);
29-
$blueScreen->addAction([self::class, 'renderLatteUnknownMacro']);
30-
$blueScreen->addFileGenerator(function (string $file) {
31-
return substr($file, -6) === '.latte'
32-
? "{block content}\n\$END\$"
33-
: null;
34-
});
35-
Tracy\Debugger::addSourceMapper([self::class, 'mapLatteSourceCode']);
36-
}
37-
3826
$blueScreen->addAction([self::class, 'renderMemberAccessException']);
3927
$blueScreen->addPanel([self::class, 'renderNeonError']);
4028
}
4129

4230

43-
public static function renderLatteError(?\Throwable $e): ?array
44-
{
45-
if ($e instanceof Latte\CompileException && $e->sourceName) {
46-
return [
47-
'tab' => 'Template',
48-
'panel' => (preg_match('#\n|\?#', $e->sourceName)
49-
? ''
50-
: '<p>'
51-
. (@is_file($e->sourceName) // @ - may trigger error
52-
? '<b>File:</b> ' . Helpers::editorLink($e->sourceName, $e->sourceLine)
53-
: '<b>' . htmlspecialchars($e->sourceName . ($e->sourceLine ? ':' . $e->sourceLine : '')) . '</b>')
54-
. '</p>')
55-
. BlueScreen::highlightFile($e->sourceCode, $e->sourceLine, 15, false),
56-
];
57-
}
58-
59-
return null;
60-
}
61-
62-
63-
public static function renderLatteUnknownMacro(?\Throwable $e): ?array
64-
{
65-
if (
66-
$e instanceof Latte\CompileException
67-
&& $e->sourceName
68-
&& @is_file($e->sourceName) // @ - may trigger error
69-
&& (preg_match('#Unknown macro (\{\w+)\}, did you mean (\{\w+)\}\?#A', $e->getMessage(), $m)
70-
|| preg_match('#Unknown attribute (n:\w+), did you mean (n:\w+)\?#A', $e->getMessage(), $m))
71-
) {
72-
return [
73-
'link' => Helpers::editorUri($e->sourceName, $e->sourceLine, 'fix', $m[1], $m[2]),
74-
'label' => 'fix it',
75-
];
76-
}
77-
78-
return null;
79-
}
80-
81-
82-
/** @return array{file: string, line: int, label: string, active: bool} */
83-
public static function mapLatteSourceCode(string $file, int $line): ?array
84-
{
85-
if (!strpos($file, '.latte--')) {
86-
return null;
87-
}
88-
89-
$lines = file($file);
90-
if (
91-
!preg_match('#^/(?:\*\*|/) source: (\S+\.latte)#m', implode('', array_slice($lines, 0, 10)), $m)
92-
|| !@is_file($m[1]) // @ - may trigger error
93-
) {
94-
return null;
95-
}
96-
97-
$file = $m[1];
98-
$line = $line && preg_match('#/\* line (\d+) \*/#', $lines[$line - 1], $m) ? (int) $m[1] : 0;
99-
return ['file' => $file, 'line' => $line, 'label' => 'Latte', 'active' => true];
100-
}
101-
102-
10331
public static function renderMemberAccessException(?\Throwable $e): ?array
10432
{
10533
if (!$e instanceof Nette\MemberAccessException && !$e instanceof \LogicException) {

0 commit comments

Comments
 (0)