• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

i-net-software / jlessc / #614562957

05 Dec 2023 02:31PM CUT coverage: 92.59%. First build
#614562957

travis-ci

3586 of 3873 relevant lines covered (92.59%)

1.92 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.33
/src/com/inet/lib/less/LessObject.java
1
/**
2
 * MIT License (MIT)
3
 *
4
 * Copyright (c) 2014 - 2015 Volker Berlin
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7
 * of this software and associated documentation files (the "Software"), to deal
8
 * in the Software without restriction, including without limitation the rights
9
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
 * copies of the Software, and to permit persons to whom the Software is
11
 * furnished to do so, subject to the following conditions:
12
 * 
13
 * The above copyright notice and this permission notice shall be included in
14
 * all copies or substantial portions of the Software.
15
 * 
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
 * UT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
 * THE SOFTWARE.
23
 *
24
 * @author Volker Berlin
25
 * @license: The MIT license <http://opensource.org/licenses/MIT>
26
 */
27
package com.inet.lib.less;
28

29
import javax.annotation.Nonnull;
30

31
/**
32
 * A base object for the parser that hold a parse position.
33
 */
34
class LessObject {
35

36
    String filename;
37

38
    int    line, column;
39

40
    /**
41
     * Only used from LessLookAheadReader
42
     * @param filename the name of the less file, can be null if a string is parsed.
43
     */
44
    LessObject( String filename ) {
3✔
45
        this.filename = filename;
3✔
46
    }
3✔
47

48
    /**
49
     * Create a new instance with filename, line number and column position from the LessObject.
50
     * 
51
     * @param obj
52
     *            another LessObject with parse position.
53
     */
54
    LessObject( LessObject obj ) {
3✔
55
        this.filename = obj.filename;
3✔
56
        this.line = obj.line;
3✔
57
        this.column = obj.column;
3✔
58
    }
3✔
59

60
    /**
61
     * Create a LessException with filename, line number and column of the current object.
62
     * @param msg the error message.
63
     * @return the exception
64
     */
65
    @Nonnull
66
    LessException createException( String msg ) {
67
        LessException lessEx = new LessException( msg );
3✔
68
        lessEx.addPosition( filename, line, column );
3✔
69
        return lessEx;
3✔
70
    }
71

72
    /**
73
     * Create a LessException with filename, line number and column of the current object.
74
     * @param msg the error message.
75
     * @param cause the cause
76
     * @return the exception
77
     */
78
    @Nonnull
79
    LessException createException( String msg, Throwable cause ) {
80
        LessException lessEx = new LessException( msg, cause );
×
81
        lessEx.addPosition( filename, line, column );
×
82
        return lessEx;
×
83
    }
84

85
    /**
86
     * If cause is already a LessException then filename, line number and column of the current object are added to the less stacktrace.
87
     * With any other type of exception a new LessException is created.
88
     * @param cause the cause
89
     * @return the exception
90
     */
91
    @Nonnull
92
    LessException createException( Throwable cause ) {
93
        LessException lessEx = cause.getClass() == LessException.class ? (LessException)cause : new LessException( cause );
3✔
94
        lessEx.addPosition( filename, line, column );
3✔
95
        return lessEx;
3✔
96
    }
97

98
    /**
99
     * Get the file name in which the current object is define.
100
     * @return the filename, can be null if a string was parsed.
101
     */
102
    String getFileName() {
103
        return filename;
3✔
104
    }
105
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc