Skip to content

Commit f0c20e4

Browse files
committed
removed bridge for Latte
1 parent 16b82e8 commit f0c20e4

File tree

1 file changed

+1
-71
lines changed

1 file changed

+1
-71
lines changed

src/Bridges/Nette/Bridge.php

Lines changed: 1 addition & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -9,95 +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(fn(string $file) => substr($file, -6) === '.latte'
31-
? "{block content}\n\$END\$"
32-
: null);
33-
Tracy\Debugger::addSourceMapper([self::class, 'mapLatteSourceCode']);
34-
}
35-
3626
$blueScreen->addAction([self::class, 'renderMemberAccessException']);
3727
$blueScreen->addPanel([self::class, 'renderNeonError']);
3828
}
3929

4030

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

0 commit comments

Comments
 (0)