Completed
Push — master ( 6054a8...c11aa8 )
by Kacper
04:06
created

Java::getAliases()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 7
Ratio 87.5 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 1
eloc 5
c 2
b 1
f 0
nc 1
nop 0
dl 7
loc 8
rs 9.4285
1
<?php
2
/**
3
 * Highlighter
4
 *
5
 * Copyright (C) 2016, Some right reserved.
6
 *
7
 * @author Kacper "Kadet" Donat <[email protected]>
8
 *
9
 * Contact with author:
10
 * Xmpp: [email protected]
11
 * E-mail: [email protected]
12
 *
13
 * From Kadet with love.
14
 */
15
16
namespace Kadet\Highlighter\Language;
17
18
19
use Kadet\Highlighter\Matcher\RegexMatcher;
20
use Kadet\Highlighter\Matcher\WordMatcher;
21
use Kadet\Highlighter\Parser\Token\Token;
22
23
class Java extends CSharp // evil
24
{
25
    public function setupRules()
26
    {
27
        parent::setupRules();
28
29
        $this->rules->rule('keyword')->setMatcher(new WordMatcher([
30
            'abstract', 'continue', 'for', 'new', 'switch', 'assert', 'default', 'goto', 'package', 'synchronized',
31
            'do', 'if', 'private', 'this', 'break', 'double', 'implements', 'protected', 'throw', 'else', 'import',
32
            'public', 'throws', 'case', 'enum', 'instanceof', 'return', 'transient', 'catch', 'extends', 'try', 'final',
33
            'interface', 'static', 'class', 'finally', 'strictfp', 'volatile', 'const', 'native', 'super', 'while'
34
        ]));
35
36
        $this->rules->rule('symbol.annotation')->setMatcher(new RegexMatcher('/(@[\w\.]+)\s*(?:(?P<arguments>\((?>[^()]+|(?&arguments))*\))?)/si', [
37
            1 => Token::NAME
38
        ]));
39
    }
40
41
    public function getIdentifier()
42
    {
43
        return 'java';
44
    }
45
46 View Code Duplication
    public static function getMetadata()
47
    {
48
        return [
49
            'name'      => ['java'],
50
            'mime'      => ['text/x-java'],
51
            'extension' => ['*.java']
52
        ];
53
    }
54
}
55