GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — processing4/java/src/processing/mode/java/ProblemFactory.java at main · D-I-R-M/processing4

Expand file tree

/

ProblemFactory.java

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
67 lines (52 loc) · 1.65 KB
/

ProblemFactory.java

Copy path

File metadata and controls

67 lines (52 loc) · 1.65 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package processing.mode.java;
import java.util.List;
import java.util.OptionalInt;
import java.util.stream.IntStream;
import processing.app.Problem;
import processing.app.ui.Editor;
import processing.mode.java.preproc.PdePreprocessIssue;
/**
* Factory which helps create {Problem}s during preprocessing.
*/
public class ProblemFactory {
/**
* Create a new {Problem}.
*
* @param pdePreprocessIssue The preprocess issue found.
* @param tabStarts The list of line numbers on which each tab starts.
* @return Newly created problem.
*/
public static Problem build(PdePreprocessIssue pdePreprocessIssue, List<Integer> tabStarts) {
int line = pdePreprocessIssue.getLine();
TabLine tabLine = getTab(tabStarts, line);
int tab = tabLine.getTab();
int localLine = tabLine.getLineInTab();
int col = pdePreprocessIssue.getCharPositionInLine();
String message = pdePreprocessIssue.getMsg();
if (col == 0) {
col = 1;
}
return new SyntaxProblem(
tab,
localLine,
message,
0,
col
);
}
/**
* Get the local tab and line number for a global line.
*
* @param tabStarts The lines on which each tab starts.
* @param line The global line to locate as a local line.
* @return The local tab number and local line number.
*/
protected static TabLine getTab(List<Integer> tabStarts, int line) {
OptionalInt tabMaybe = IntStream.range(0, tabStarts.size())
.filter((index) -> line >= tabStarts.get(index))
.max();
int tab = tabMaybe.orElse(0);
int localLine = line - tabStarts.get(tab);
return new TabLine(tab, line, localLine);
}
}
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.