package dyvil.tools.parsing.position;

public interface ICodePosition
{
	ICodePosition ORIGIN = new CodePosition(1, 0, 1);

	static ICodePosition between(ICodePosition start, ICodePosition end)
	{
		return new CodePosition(start.endLine(), end.startLine(), start.endIndex(), end.startIndex());
	}
	
	int startIndex();
	
	int endIndex();
	
	int startLine();
	
	int endLine();
	
	ICodePosition raw();
	
	ICodePosition to(ICodePosition end);

	default boolean before(ICodePosition position)
	{
		return this.endIndex() < position.startIndex();
	}

	default boolean after(ICodePosition position)
	{
		return this.startIndex() > position.endIndex();
	}
}

@@ -186,24 +186,166 @@
 ion end)%0A%09%7B%0A
+%09%09int startIndex = start.endIndex();%0A%09%09int endIndex = end.startIndex();%0A%09%09if (startIndex == endIndex)%0A%09%09%7B%0A%09%09%09startIndex--;%0A%09%09%09endIndex++;%0A%09%09%7D%0A
 %09%09return new
@@ -401,45 +401,30 @@
 tart
-.end
 Index
-()
 , end
-.start
 Index
-()
 );%0A%09%7D%0A
-%09
 %0A
+
 %09int
@@ -434,26 +434,25 @@
 artIndex();%0A
-%09
 %0A
+
 %09int endInde
@@ -452,26 +452,25 @@
 endIndex();%0A
-%09
 %0A
+
 %09int startLi
@@ -475,18 +475,17 @@
 Line();%0A
-%09
 %0A
+
 %09int end
@@ -488,26 +488,25 @@
  endLine();%0A
-%09
 %0A
+
 %09ICodePositi
@@ -515,17 +515,16 @@
  raw();%0A
-%09
 %0A%09ICodeP

Fix empty Code Position