Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comments from all code before sometimes get interpreted as JavaDoc #88

Open
JonathanTheDev opened this issue Dec 15, 2023 · 2 comments · May be fixed by #126
Open

Comments from all code before sometimes get interpreted as JavaDoc #88

JonathanTheDev opened this issue Dec 15, 2023 · 2 comments · May be fixed by #126

Comments

@JonathanTheDev
Copy link

JonathanTheDev commented Dec 15, 2023

I'm converting a project from Java to C# and I have a specific file which is causing problems. In this file it seems that all comments get interpreted as JavaDoc comments. So every time there is a comment in the document, it gets added as a a comment to all the next properties or methods in the document.

It's pretty clear in this example:

Input:

package al.artofsoul.data;

import static al.artofsoul.ndihma.Artist.*;
import static al.artofsoul.ndihma.Ora.*;

import java.util.ArrayList;

import org.newdawn.slick.opengl.Texture;

public class Armiku implements Entity{
	private int width, height, currentCheckpoint;
	private float speed, x, y, health, startHealth;// hiddenHealth;
	private Texture texture, healthBackground, healthForeground, healthBorder;
	private Pllaka filloPllaka;
	private boolean first, alive;
	private PllakaFusha grid;
	
	private ArrayList<Checkpoint> checkpoints;
	private int[] directions;
	
	//default constructor
	public Armiku(int tilleX, int tileY, PllakaFusha grid) {
		this.texture = QuickLoad("/res/armiku/armikBlue32");
		this.healthBackground = QuickLoad("/res/armiku/healthBack"); // enemy statusi photo
		this.healthForeground = QuickLoad("/res/armiku/healthForeg");
		this.healthBorder = QuickLoad("/res/armiku/healthBord");
		this.filloPllaka = grid.merrPllaka(tilleX, tileY);
		this.x = filloPllaka.getX();
		this.y = filloPllaka.getY();
		this.width = TILE_SIZE;
		this.height = TILE_SIZE;
		this.speed = 40;
		this.health = 40;
		this.startHealth = health;
		this.grid = grid;
		this.first = true;
		this.alive = true;
		this.checkpoints = new ArrayList<Checkpoint>();
		this.directions = new int [2];
		// x direction
		this.directions[0] = 0;
		// y direction
		this.directions[1] = 0;
		this.directions = findNextD(filloPllaka);
		this.currentCheckpoint = 0;
		populateCheckpointlist();
	
	}
	
	public Armiku(Texture texture, Pllaka filloPllaka, PllakaFusha grid, int width, 
			int height, float speed, float health){
		this.texture = texture;
		this.healthBackground = QuickLoad("/res/armiku/healthBack"); // enemy statusi photo
		this.healthForeground = QuickLoad("/res/armiku/healthForeg");
		this.healthBorder = QuickLoad("/res/armiku/healthBord");
		this.filloPllaka = filloPllaka;
		this.x = filloPllaka.getX();
		this.y = filloPllaka.getY();
		this.width = width;
		this.height = height;
		this.speed = speed;
		this.health = health;
		this.startHealth = health;
		//this.hiddenHealth = health;
		this.grid = grid;
		this.first = true;
		this.alive = true;
		this.checkpoints = new ArrayList<Checkpoint>();
		this.directions = new int [2];
		// x direction
		this.directions[0] = 0;
		// y direction
		this.directions[1] = 0;
		this.directions = findNextD(filloPllaka);
		this.currentCheckpoint = 0;
		populateCheckpointlist();
	}
	
	public void update(){
		// check if it's the first time this class is updated, if so do nothing
		if (first)
			first = false;
		else {
			if (checkpointReached()) {
				//check if there are more checkpoints before moving on
				if (currentCheckpoint + 1 == checkpoints.size())
					endOfMazeReached();
					//System.out.println("Enamy reached end of maze");
				else
					currentCheckpoint++;
			} else {
				// if not at a checkpoint, continue in current direction
				x += Delta() * checkpoints.get(currentCheckpoint).getxDirection() * speed;
				y += Delta() * checkpoints.get(currentCheckpoint).getyDirection() * speed;
			}
		}
	}
	// run when last checkpoint is reached by enemy
	private void endOfMazeReached() {
		Lojtari.modifyLives(-1);
		die();
	}

	private boolean checkpointReached(){
		boolean reached = false;
		Pllaka t = checkpoints.get(currentCheckpoint).getPllaka();
		// check if position reached tile within variance of 3 (arbitrary)
		if ( x > t.getX() - 3 && 
				x < t.getX() + 3 &&
				y > t.getY() - 3 &&
				y < t.getY() + 3){
		
			reached = true;
			x = t.getX();
			y = t.getY();
		}	
		return reached;
	}
	
	private void populateCheckpointlist() {
		//Add first checkpoint manually based on filloPllaka
		checkpoints.add(findNextC(filloPllaka, directions = findNextD(filloPllaka)));
		
		int counter = 0;
		boolean cont = true;
		while (cont){
			int[] currentD = findNextD(checkpoints.get(counter).getPllaka());
			//check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
			if (currentD[0] == 2 || counter == 20) {
				cont = false;
			} else {
				checkpoints.add(findNextC(checkpoints.get(counter).getPllaka(),
						directions = findNextD(checkpoints.get(counter).getPllaka())));
			}
			counter++;
		}
	}
	
	private Checkpoint findNextC(Pllaka s, int[] dir) {
		Pllaka next = null;
		Checkpoint c = null;
		
		//boolean per te deklaruar nese next kontrolli eshte gjetur
		boolean found = false;
		// Integer to increment each loop
		int counter = 1;
		
		while (!found) {
			if(s.getXPlace() + dir[0] * counter == grid.getPllakaWide() ||
					s.getYPlace() + dir[1] * counter == grid.getPllakaHigh() ||
					s.getType() != 
					grid.merrPllaka(s.getXPlace() + dir[0] * counter,
							s.getYPlace() + dir[1] * counter).getType()){
				found = true;
				// move counter back 1 to find pllaka before new PllakaType
				counter -= 1;
				next = grid.merrPllaka(s.getXPlace() + dir[0] * counter,
						s.getYPlace() + dir[1] * counter);
			}	
			counter++;
		}
		c = new Checkpoint (next, dir[0], dir[1]);
		return c;
	}
	
	private int [] findNextD(Pllaka s) {
		int[] dir = new int[2];
		Pllaka u = grid.merrPllaka(s.getXPlace(), s.getYPlace() - 1); // Up
		Pllaka r = grid.merrPllaka(s.getXPlace() + 1, s.getYPlace()); // right
		Pllaka d = grid.merrPllaka(s.getXPlace(), s.getYPlace() + 1); // down
		Pllaka l = grid.merrPllaka(s.getXPlace() - 1, s.getYPlace()); // left
		//check if current inhabited pllakatype maches pallakatype above, right, down or left
		if (s.getType() == u.getType() && directions[1] != 1) {
			dir[0] = 0;
			dir[1] = -1;
		} else if (s.getType() == r.getType() && directions[0] != -1) {
			dir[0] = 1;
			dir[1] = 0;
		} else if (s.getType() == d.getType() && directions[1] != -1) {
			dir[0] = 0;
			dir[1] = 1;
		} else if (s.getType() == l.getType() && directions[0] != 1) {
			dir[0] = -1;
			dir[1] = 0;
		} else {
			dir[0] = 2;
			dir[1] = 2;
			//System.out.println("No dierction found");
		}
		return dir;
	}
	
	// take damage from external source
	public void damage(int amount) {
		health -= amount;
		if (health <= 0) {
			die();
			Lojtari.modifyGold(5);
		}
	}
	
	private void die(){
		alive = false;
	}
	
	public void draw(){
		float healthPercentage = health / startHealth;
		// enemy texture 
		VizatoKatrorTex(texture, x, y, width, height);
		// health bar textures
		VizatoKatrorTex(healthBackground, x, y - 16, width, 8);
		VizatoKatrorTex(healthForeground, x, y - 16, TILE_SIZE * healthPercentage, 8);
		VizatoKatrorTex(healthBorder, x, y - 16, width, 8);
	}

	/*
	 * 

	
	public void reduceHiddenHealth(float amount) {
		hiddenHealth -= amount;
	}

	public float getHiddenHealth() {
		return hiddenHealth;
	}
	 */
	public int getWidth() {
		return width;
	}

	public void setWidth(int width) {
		this.width = width;
	}

	public int getHeight() {
		return height;
	}

	public void setHeight(int height) {
		this.height = height;
	}

	public float getHealth() {
		return health;
	}

	public void setHealth(int health) {
		this.health = health;
	}

	public float getSpeed() {
		return speed;
	}

	public void setSpeed(float speed) {
		this.speed = speed;
	}

	public float getX() {
		return x;
	}

	public void setX(float x) {
		this.x = x;
	}

	public float getY() {
		return y;
	}

	public void setY(float y) {
		this.y = y;
	}

	public Texture getTexture() {
		return texture;
	}

	public void setTexture(Texture texture) {
		this.texture = texture;
	}
	
	public void setTexture (String textureName) {
		this.texture = QuickLoad(textureName);
	}

	public Pllaka getFilloPllaka() {
		return filloPllaka;
	}

	public void setFilloPllaka(Pllaka filloPllaka) {
		this.filloPllaka = filloPllaka;
	}

	public boolean isFirst() {
		return first;
	}

	public void setFirst(boolean first) {
		this.first = first;
	}
	public PllakaFusha getTileGrid(){
		return grid;
	}
	public boolean isAlive(){
		return alive;
	}
	

}

Output:

using Al.Artofsoul.Ndihma;
using Java.Util;
using Org.Newdawn.Slick.Opengl;

namespace Al.Artofsoul.Data
{
    public class Armiku : Entity
    {
        private int width, height, currentCheckpoint;
        private float speed, x, y, health, startHealth; // hiddenHealth
        // hiddenHealth
        private Texture texture, healthBackground, healthForeground, healthBorder;
        // hiddenHealth
        private Pllaka filloPllaka;
        // hiddenHealth
        private bool first, alive;
        // hiddenHealth
        private PllakaFusha grid;
        // hiddenHealth
        private List<Checkpoint> checkpoints;
        // hiddenHealth
        private int[] directions;
        // hiddenHealth
        //default constructor
        public Armiku(int tilleX, int tileY, PllakaFusha grid)
        {
            this.texture = QuickLoad("/res/armiku/armikBlue32");
            this.healthBackground = QuickLoad("/res/armiku/healthBack"); // enemy statusi photo
            this.healthForeground = QuickLoad("/res/armiku/healthForeg");
            this.healthBorder = QuickLoad("/res/armiku/healthBord");
            this.filloPllaka = grid.MerrPllaka(tilleX, tileY);
            this.x = filloPllaka.GetX();
            this.y = filloPllaka.GetY();
            this.width = TILE_SIZE;
            this.height = TILE_SIZE;
            this.speed = 40;
            this.health = 40;
            this.startHealth = health;
            this.grid = grid;
            this.first = true;
            this.alive = true;
            this.checkpoints = new List<Checkpoint>();
            this.directions = new int[2];

            // x direction
            this.directions[0] = 0;

            // y direction
            this.directions[1] = 0;
            this.directions = FindNextD(filloPllaka);
            this.currentCheckpoint = 0;
            PopulateCheckpointlist();
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        public Armiku(Texture texture, Pllaka filloPllaka, PllakaFusha grid, int width, int height, float speed, float health)
        {
            this.texture = texture;
            this.healthBackground = QuickLoad("/res/armiku/healthBack"); // enemy statusi photo
            this.healthForeground = QuickLoad("/res/armiku/healthForeg");
            this.healthBorder = QuickLoad("/res/armiku/healthBord");
            this.filloPllaka = filloPllaka;
            this.x = filloPllaka.GetX();
            this.y = filloPllaka.GetY();
            this.width = width;
            this.height = height;
            this.speed = speed;
            this.health = health;
            this.startHealth = health;

            //this.hiddenHealth = health;
            this.grid = grid;
            this.first = true;
            this.alive = true;
            this.checkpoints = new List<Checkpoint>();
            this.directions = new int[2];

            // x direction
            this.directions[0] = 0;

            // y direction
            this.directions[1] = 0;
            this.directions = FindNextD(filloPllaka);
            this.currentCheckpoint = 0;
            PopulateCheckpointlist();
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        public virtual void Update()
        {

            // check if it's the first time this class is updated, if so do nothing
            if (first)
                first = false;
            else
            {
                if (CheckpointReached())
                {

                    //check if there are more checkpoints before moving on
                    if (currentCheckpoint + 1 == checkpoints.Count)
                        EndOfMazeReached();
                    else

                        //System.out.println("Enamy reached end of maze");
                        currentCheckpoint++;
                }
                else
                {

                    // if not at a checkpoint, continue in current direction
                    x += Delta() * checkpoints[currentCheckpoint].GetxDirection() * speed;
                    y += Delta() * checkpoints[currentCheckpoint].GetyDirection() * speed;
                }
            }
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        private void EndOfMazeReached()
        {
            Lojtari.ModifyLives(-1);
            Die();
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        private bool CheckpointReached()
        {
            bool reached = false;
            Pllaka t = checkpoints[currentCheckpoint].GetPllaka();

            // check if position reached tile within variance of 3 (arbitrary)
            if (x > t.GetX() - 3 && x < t.GetX() + 3 && y > t.GetY() - 3 && y < t.GetY() + 3)
            {
                reached = true;
                x = t.GetX();
                y = t.GetY();
            }

            return reached;
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        // check if position reached tile within variance of 3 (arbitrary)
        private void PopulateCheckpointlist()
        {

            //Add first checkpoint manually based on filloPllaka
            checkpoints.Add(FindNextC(filloPllaka, directions = FindNextD(filloPllaka)));
            int counter = 0;
            bool cont = true;
            while (cont)
            {
                int[] currentD = FindNextD(checkpoints[counter].GetPllaka());

                //check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
                if (currentD[0] == 2 || counter == 20)
                {
                    cont = false;
                }
                else
                {
                    checkpoints.Add(FindNextC(checkpoints[counter].GetPllaka(), directions = FindNextD(checkpoints[counter].GetPllaka())));
                }

                counter++;
            }
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        // check if position reached tile within variance of 3 (arbitrary)
        //Add first checkpoint manually based on filloPllaka
        //check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
        private Checkpoint FindNextC(Pllaka s, int[] dir)
        {
            Pllaka next = null;
            Checkpoint c = null;

            //boolean per te deklaruar nese next kontrolli eshte gjetur
            bool found = false;

            // Integer to increment each loop
            int counter = 1;
            while (!found)
            {
                if (s.GetXPlace() + dir[0] * counter == grid.GetPllakaWide() || s.GetYPlace() + dir[1] * counter == grid.GetPllakaHigh() || s.GetType() != grid.MerrPllaka(s.GetXPlace() + dir[0] * counter, s.GetYPlace() + dir[1] * counter).GetType())
                {
                    found = true;

                    // move counter back 1 to find pllaka before new PllakaType
                    counter -= 1;
                    next = grid.MerrPllaka(s.GetXPlace() + dir[0] * counter, s.GetYPlace() + dir[1] * counter);
                }

                counter++;
            }

            c = new Checkpoint(next, dir[0], dir[1]);
            return c;
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        // check if position reached tile within variance of 3 (arbitrary)
        //Add first checkpoint manually based on filloPllaka
        //check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
        //boolean per te deklaruar nese next kontrolli eshte gjetur
        // Integer to increment each loop
        // move counter back 1 to find pllaka before new PllakaType
        private int[] FindNextD(Pllaka s)
        {
            int[] dir = new int[2];
            Pllaka u = grid.MerrPllaka(s.GetXPlace(), s.GetYPlace() - 1); // Up
            Pllaka r = grid.MerrPllaka(s.GetXPlace() + 1, s.GetYPlace()); // right
            Pllaka d = grid.MerrPllaka(s.GetXPlace(), s.GetYPlace() + 1); // down
            Pllaka l = grid.MerrPllaka(s.GetXPlace() - 1, s.GetYPlace()); // left

            //check if current inhabited pllakatype maches pallakatype above, right, down or left
            if (s.GetType() == u.GetType() && directions[1] != 1)
            {
                dir[0] = 0;
                dir[1] = -1;
            }
            else if (s.GetType() == r.GetType() && directions[0] != -1)
            {
                dir[0] = 1;
                dir[1] = 0;
            }
            else if (s.GetType() == d.GetType() && directions[1] != -1)
            {
                dir[0] = 0;
                dir[1] = 1;
            }
            else if (s.GetType() == l.GetType() && directions[0] != 1)
            {
                dir[0] = -1;
                dir[1] = 0;
            }
            else
            {
                dir[0] = 2;
                dir[1] = 2; //System.out.println("No dierction found");
            }

            return dir;
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        // check if position reached tile within variance of 3 (arbitrary)
        //Add first checkpoint manually based on filloPllaka
        //check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
        //boolean per te deklaruar nese next kontrolli eshte gjetur
        // Integer to increment each loop
        // move counter back 1 to find pllaka before new PllakaType
        // Up
        // right
        // down
        // left
        //check if current inhabited pllakatype maches pallakatype above, right, down or left
        //System.out.println("No dierction found");
        // take damage from external source
        public virtual void Damage(int amount)
        {
            health -= amount;
            if (health <= 0)
            {
                Die();
                Lojtari.ModifyGold(5);
            }
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        // check if position reached tile within variance of 3 (arbitrary)
        //Add first checkpoint manually based on filloPllaka
        //check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
        //boolean per te deklaruar nese next kontrolli eshte gjetur
        // Integer to increment each loop
        // move counter back 1 to find pllaka before new PllakaType
        // Up
        // right
        // down
        // left
        //check if current inhabited pllakatype maches pallakatype above, right, down or left
        //System.out.println("No dierction found");
        // take damage from external source
        private void Die()
        {
            alive = false;
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        // check if position reached tile within variance of 3 (arbitrary)
        //Add first checkpoint manually based on filloPllaka
        //check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
        //boolean per te deklaruar nese next kontrolli eshte gjetur
        // Integer to increment each loop
        // move counter back 1 to find pllaka before new PllakaType
        // Up
        // right
        // down
        // left
        //check if current inhabited pllakatype maches pallakatype above, right, down or left
        //System.out.println("No dierction found");
        // take damage from external source
        public virtual void Draw()
        {
            float healthPercentage = health / startHealth;

            // enemy texture 
            VizatoKatrorTex(texture, x, y, width, height);

            // health bar textures
            VizatoKatrorTex(healthBackground, x, y - 16, width, 8);
            VizatoKatrorTex(healthForeground, x, y - 16, TILE_SIZE * healthPercentage, 8);
            VizatoKatrorTex(healthBorder, x, y - 16, width, 8);
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        // check if position reached tile within variance of 3 (arbitrary)
        //Add first checkpoint manually based on filloPllaka
        //check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
        //boolean per te deklaruar nese next kontrolli eshte gjetur
        // Integer to increment each loop
        // move counter back 1 to find pllaka before new PllakaType
        // Up
        // right
        // down
        // left
        //check if current inhabited pllakatype maches pallakatype above, right, down or left
        //System.out.println("No dierction found");
        // take damage from external source
        // enemy texture 
        // health bar textures
        /*
	 * 

	
	public void reduceHiddenHealth(float amount) {
		hiddenHealth -= amount;
	}

	public float getHiddenHealth() {
		return hiddenHealth;
	}
	 */
        public virtual int GetWidth()
        {
            return width;
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        // check if position reached tile within variance of 3 (arbitrary)
        //Add first checkpoint manually based on filloPllaka
        //check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
        //boolean per te deklaruar nese next kontrolli eshte gjetur
        // Integer to increment each loop
        // move counter back 1 to find pllaka before new PllakaType
        // Up
        // right
        // down
        // left
        //check if current inhabited pllakatype maches pallakatype above, right, down or left
        //System.out.println("No dierction found");
        // take damage from external source
        // enemy texture 
        // health bar textures
        /*
	 * 

	
	public void reduceHiddenHealth(float amount) {
		hiddenHealth -= amount;
	}

	public float getHiddenHealth() {
		return hiddenHealth;
	}
	 */
        public virtual void SetWidth(int width)
        {
            this.width = width;
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        // check if position reached tile within variance of 3 (arbitrary)
        //Add first checkpoint manually based on filloPllaka
        //check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
        //boolean per te deklaruar nese next kontrolli eshte gjetur
        // Integer to increment each loop
        // move counter back 1 to find pllaka before new PllakaType
        // Up
        // right
        // down
        // left
        //check if current inhabited pllakatype maches pallakatype above, right, down or left
        //System.out.println("No dierction found");
        // take damage from external source
        // enemy texture 
        // health bar textures
        /*
	 * 

	
	public void reduceHiddenHealth(float amount) {
		hiddenHealth -= amount;
	}

	public float getHiddenHealth() {
		return hiddenHealth;
	}
	 */
        public virtual int GetHeight()
        {
            return height;
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        // check if position reached tile within variance of 3 (arbitrary)
        //Add first checkpoint manually based on filloPllaka
        //check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
        //boolean per te deklaruar nese next kontrolli eshte gjetur
        // Integer to increment each loop
        // move counter back 1 to find pllaka before new PllakaType
        // Up
        // right
        // down
        // left
        //check if current inhabited pllakatype maches pallakatype above, right, down or left
        //System.out.println("No dierction found");
        // take damage from external source
        // enemy texture 
        // health bar textures
        /*
	 * 

	
	public void reduceHiddenHealth(float amount) {
		hiddenHealth -= amount;
	}

	public float getHiddenHealth() {
		return hiddenHealth;
	}
	 */
        public virtual void SetHeight(int height)
        {
            this.height = height;
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        // check if position reached tile within variance of 3 (arbitrary)
        //Add first checkpoint manually based on filloPllaka
        //check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
        //boolean per te deklaruar nese next kontrolli eshte gjetur
        // Integer to increment each loop
        // move counter back 1 to find pllaka before new PllakaType
        // Up
        // right
        // down
        // left
        //check if current inhabited pllakatype maches pallakatype above, right, down or left
        //System.out.println("No dierction found");
        // take damage from external source
        // enemy texture 
        // health bar textures
        /*
	 * 

	
	public void reduceHiddenHealth(float amount) {
		hiddenHealth -= amount;
	}

	public float getHiddenHealth() {
		return hiddenHealth;
	}
	 */
        public virtual float GetHealth()
        {
            return health;
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        // check if position reached tile within variance of 3 (arbitrary)
        //Add first checkpoint manually based on filloPllaka
        //check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
        //boolean per te deklaruar nese next kontrolli eshte gjetur
        // Integer to increment each loop
        // move counter back 1 to find pllaka before new PllakaType
        // Up
        // right
        // down
        // left
        //check if current inhabited pllakatype maches pallakatype above, right, down or left
        //System.out.println("No dierction found");
        // take damage from external source
        // enemy texture 
        // health bar textures
        /*
	 * 

	
	public void reduceHiddenHealth(float amount) {
		hiddenHealth -= amount;
	}

	public float getHiddenHealth() {
		return hiddenHealth;
	}
	 */
        public virtual void SetHealth(int health)
        {
            this.health = health;
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        // check if position reached tile within variance of 3 (arbitrary)
        //Add first checkpoint manually based on filloPllaka
        //check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
        //boolean per te deklaruar nese next kontrolli eshte gjetur
        // Integer to increment each loop
        // move counter back 1 to find pllaka before new PllakaType
        // Up
        // right
        // down
        // left
        //check if current inhabited pllakatype maches pallakatype above, right, down or left
        //System.out.println("No dierction found");
        // take damage from external source
        // enemy texture 
        // health bar textures
        /*
	 * 

	
	public void reduceHiddenHealth(float amount) {
		hiddenHealth -= amount;
	}

	public float getHiddenHealth() {
		return hiddenHealth;
	}
	 */
        public virtual float GetSpeed()
        {
            return speed;
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        // check if position reached tile within variance of 3 (arbitrary)
        //Add first checkpoint manually based on filloPllaka
        //check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
        //boolean per te deklaruar nese next kontrolli eshte gjetur
        // Integer to increment each loop
        // move counter back 1 to find pllaka before new PllakaType
        // Up
        // right
        // down
        // left
        //check if current inhabited pllakatype maches pallakatype above, right, down or left
        //System.out.println("No dierction found");
        // take damage from external source
        // enemy texture 
        // health bar textures
        /*
	 * 

	
	public void reduceHiddenHealth(float amount) {
		hiddenHealth -= amount;
	}

	public float getHiddenHealth() {
		return hiddenHealth;
	}
	 */
        public virtual void SetSpeed(float speed)
        {
            this.speed = speed;
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        // check if position reached tile within variance of 3 (arbitrary)
        //Add first checkpoint manually based on filloPllaka
        //check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
        //boolean per te deklaruar nese next kontrolli eshte gjetur
        // Integer to increment each loop
        // move counter back 1 to find pllaka before new PllakaType
        // Up
        // right
        // down
        // left
        //check if current inhabited pllakatype maches pallakatype above, right, down or left
        //System.out.println("No dierction found");
        // take damage from external source
        // enemy texture 
        // health bar textures
        /*
	 * 

	
	public void reduceHiddenHealth(float amount) {
		hiddenHealth -= amount;
	}

	public float getHiddenHealth() {
		return hiddenHealth;
	}
	 */
        public virtual float GetX()
        {
            return x;
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        // check if position reached tile within variance of 3 (arbitrary)
        //Add first checkpoint manually based on filloPllaka
        //check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
        //boolean per te deklaruar nese next kontrolli eshte gjetur
        // Integer to increment each loop
        // move counter back 1 to find pllaka before new PllakaType
        // Up
        // right
        // down
        // left
        //check if current inhabited pllakatype maches pallakatype above, right, down or left
        //System.out.println("No dierction found");
        // take damage from external source
        // enemy texture 
        // health bar textures
        /*
	 * 

	
	public void reduceHiddenHealth(float amount) {
		hiddenHealth -= amount;
	}

	public float getHiddenHealth() {
		return hiddenHealth;
	}
	 */
        public virtual void SetX(float x)
        {
            this.x = x;
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        // check if position reached tile within variance of 3 (arbitrary)
        //Add first checkpoint manually based on filloPllaka
        //check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
        //boolean per te deklaruar nese next kontrolli eshte gjetur
        // Integer to increment each loop
        // move counter back 1 to find pllaka before new PllakaType
        // Up
        // right
        // down
        // left
        //check if current inhabited pllakatype maches pallakatype above, right, down or left
        //System.out.println("No dierction found");
        // take damage from external source
        // enemy texture 
        // health bar textures
        /*
	 * 

	
	public void reduceHiddenHealth(float amount) {
		hiddenHealth -= amount;
	}

	public float getHiddenHealth() {
		return hiddenHealth;
	}
	 */
        public virtual float GetY()
        {
            return y;
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        // check if position reached tile within variance of 3 (arbitrary)
        //Add first checkpoint manually based on filloPllaka
        //check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
        //boolean per te deklaruar nese next kontrolli eshte gjetur
        // Integer to increment each loop
        // move counter back 1 to find pllaka before new PllakaType
        // Up
        // right
        // down
        // left
        //check if current inhabited pllakatype maches pallakatype above, right, down or left
        //System.out.println("No dierction found");
        // take damage from external source
        // enemy texture 
        // health bar textures
        /*
	 * 

	
	public void reduceHiddenHealth(float amount) {
		hiddenHealth -= amount;
	}

	public float getHiddenHealth() {
		return hiddenHealth;
	}
	 */
        public virtual void SetY(float y)
        {
            this.y = y;
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        // check if position reached tile within variance of 3 (arbitrary)
        //Add first checkpoint manually based on filloPllaka
        //check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
        //boolean per te deklaruar nese next kontrolli eshte gjetur
        // Integer to increment each loop
        // move counter back 1 to find pllaka before new PllakaType
        // Up
        // right
        // down
        // left
        //check if current inhabited pllakatype maches pallakatype above, right, down or left
        //System.out.println("No dierction found");
        // take damage from external source
        // enemy texture 
        // health bar textures
        /*
	 * 

	
	public void reduceHiddenHealth(float amount) {
		hiddenHealth -= amount;
	}

	public float getHiddenHealth() {
		return hiddenHealth;
	}
	 */
        public virtual Texture GetTexture()
        {
            return texture;
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        // check if position reached tile within variance of 3 (arbitrary)
        //Add first checkpoint manually based on filloPllaka
        //check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
        //boolean per te deklaruar nese next kontrolli eshte gjetur
        // Integer to increment each loop
        // move counter back 1 to find pllaka before new PllakaType
        // Up
        // right
        // down
        // left
        //check if current inhabited pllakatype maches pallakatype above, right, down or left
        //System.out.println("No dierction found");
        // take damage from external source
        // enemy texture 
        // health bar textures
        /*
	 * 

	
	public void reduceHiddenHealth(float amount) {
		hiddenHealth -= amount;
	}

	public float getHiddenHealth() {
		return hiddenHealth;
	}
	 */
        public virtual void SetTexture(Texture texture)
        {
            this.texture = texture;
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        // check if position reached tile within variance of 3 (arbitrary)
        //Add first checkpoint manually based on filloPllaka
        //check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
        //boolean per te deklaruar nese next kontrolli eshte gjetur
        // Integer to increment each loop
        // move counter back 1 to find pllaka before new PllakaType
        // Up
        // right
        // down
        // left
        //check if current inhabited pllakatype maches pallakatype above, right, down or left
        //System.out.println("No dierction found");
        // take damage from external source
        // enemy texture 
        // health bar textures
        /*
	 * 

	
	public void reduceHiddenHealth(float amount) {
		hiddenHealth -= amount;
	}

	public float getHiddenHealth() {
		return hiddenHealth;
	}
	 */
        public virtual void SetTexture(string textureName)
        {
            this.texture = QuickLoad(textureName);
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        // check if position reached tile within variance of 3 (arbitrary)
        //Add first checkpoint manually based on filloPllaka
        //check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
        //boolean per te deklaruar nese next kontrolli eshte gjetur
        // Integer to increment each loop
        // move counter back 1 to find pllaka before new PllakaType
        // Up
        // right
        // down
        // left
        //check if current inhabited pllakatype maches pallakatype above, right, down or left
        //System.out.println("No dierction found");
        // take damage from external source
        // enemy texture 
        // health bar textures
        /*
	 * 

	
	public void reduceHiddenHealth(float amount) {
		hiddenHealth -= amount;
	}

	public float getHiddenHealth() {
		return hiddenHealth;
	}
	 */
        public virtual Pllaka GetFilloPllaka()
        {
            return filloPllaka;
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        // check if position reached tile within variance of 3 (arbitrary)
        //Add first checkpoint manually based on filloPllaka
        //check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
        //boolean per te deklaruar nese next kontrolli eshte gjetur
        // Integer to increment each loop
        // move counter back 1 to find pllaka before new PllakaType
        // Up
        // right
        // down
        // left
        //check if current inhabited pllakatype maches pallakatype above, right, down or left
        //System.out.println("No dierction found");
        // take damage from external source
        // enemy texture 
        // health bar textures
        /*
	 * 

	
	public void reduceHiddenHealth(float amount) {
		hiddenHealth -= amount;
	}

	public float getHiddenHealth() {
		return hiddenHealth;
	}
	 */
        public virtual void SetFilloPllaka(Pllaka filloPllaka)
        {
            this.filloPllaka = filloPllaka;
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        // check if position reached tile within variance of 3 (arbitrary)
        //Add first checkpoint manually based on filloPllaka
        //check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
        //boolean per te deklaruar nese next kontrolli eshte gjetur
        // Integer to increment each loop
        // move counter back 1 to find pllaka before new PllakaType
        // Up
        // right
        // down
        // left
        //check if current inhabited pllakatype maches pallakatype above, right, down or left
        //System.out.println("No dierction found");
        // take damage from external source
        // enemy texture 
        // health bar textures
        /*
	 * 

	
	public void reduceHiddenHealth(float amount) {
		hiddenHealth -= amount;
	}

	public float getHiddenHealth() {
		return hiddenHealth;
	}
	 */
        public virtual bool IsFirst()
        {
            return first;
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        // check if position reached tile within variance of 3 (arbitrary)
        //Add first checkpoint manually based on filloPllaka
        //check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
        //boolean per te deklaruar nese next kontrolli eshte gjetur
        // Integer to increment each loop
        // move counter back 1 to find pllaka before new PllakaType
        // Up
        // right
        // down
        // left
        //check if current inhabited pllakatype maches pallakatype above, right, down or left
        //System.out.println("No dierction found");
        // take damage from external source
        // enemy texture 
        // health bar textures
        /*
	 * 

	
	public void reduceHiddenHealth(float amount) {
		hiddenHealth -= amount;
	}

	public float getHiddenHealth() {
		return hiddenHealth;
	}
	 */
        public virtual void SetFirst(bool first)
        {
            this.first = first;
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        // check if position reached tile within variance of 3 (arbitrary)
        //Add first checkpoint manually based on filloPllaka
        //check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
        //boolean per te deklaruar nese next kontrolli eshte gjetur
        // Integer to increment each loop
        // move counter back 1 to find pllaka before new PllakaType
        // Up
        // right
        // down
        // left
        //check if current inhabited pllakatype maches pallakatype above, right, down or left
        //System.out.println("No dierction found");
        // take damage from external source
        // enemy texture 
        // health bar textures
        /*
	 * 

	
	public void reduceHiddenHealth(float amount) {
		hiddenHealth -= amount;
	}

	public float getHiddenHealth() {
		return hiddenHealth;
	}
	 */
        public virtual PllakaFusha GetTileGrid()
        {
            return grid;
        }

        // hiddenHealth
        //default constructor
        // enemy statusi photo
        // x direction
        // y direction
        // enemy statusi photo
        //this.hiddenHealth = health;
        // x direction
        // y direction
        // check if it's the first time this class is updated, if so do nothing
        //check if there are more checkpoints before moving on
        //System.out.println("Enamy reached end of maze");
        // if not at a checkpoint, continue in current direction
        // run when last checkpoint is reached by enemy
        // check if position reached tile within variance of 3 (arbitrary)
        //Add first checkpoint manually based on filloPllaka
        //check if next direction/checkpoints exists, end after 20 checkpoints (arbitrary)
        //boolean per te deklaruar nese next kontrolli eshte gjetur
        // Integer to increment each loop
        // move counter back 1 to find pllaka before new PllakaType
        // Up
        // right
        // down
        // left
        //check if current inhabited pllakatype maches pallakatype above, right, down or left
        //System.out.println("No dierction found");
        // take damage from external source
        // enemy texture 
        // health bar textures
        /*
	 * 

	
	public void reduceHiddenHealth(float amount) {
		hiddenHealth -= amount;
	}


	public float getHiddenHealth() {
		return hiddenHealth;
	}
	 */
        public virtual bool IsAlive()
        {
            return alive;
        }
    }
}

Theese are my settings:
JavaToCSharpGui_SHv7mAUOQM

I'm using the latest release 3.0.0 on Windows 64 bit.

And here's the file that's causing trouble:
Source.zip

@javiertuya
Copy link
Contributor

I also faced this problem and have isolated it:

  • It happens when converting subclasses and interface implementations
  • It affects the comments inside a class and to all kind of comments, but not the comments before the class
  • For each comment is converted, all previous comments are included before this comments

I am now working on locating the root cause.

@javiertuya
Copy link
Contributor

I have located the root cause. To reproduce, I'm using this program with a Child class that inherits from Parent:

public class Child extends Parent {
    //comment 1
    public void method1() { }
    //comment 2
    public void method1() { }
    //comment 3
    public void method1() { }
}

The problem is in CommentsHelper.cs at this method (where I've added a debug trace)

    private static JavaAst.Node? GetPreviousSibling(JavaAst.Node parentNode, JavaParser.Position nodeBegin)
    {
        return parentNode.getChildNodes()
            .OfType<JavaAst.Node>()
            .Where(sibling => sibling is not JavaComments.Comment)
            .LastOrDefault(sibling =>
            {
                var siblingEnd = sibling.getEnd().FromOptional<JavaParser.Position>();
                System.Diagnostics.Debug.WriteLine("siblingEnd: " + siblingEnd + " - type: " + sibling.GetType() + " - sibling: " + sibling);
                return siblingEnd != null && (siblingEnd.line < nodeBegin.line || siblingEnd.line == nodeBegin.line && siblingEnd.column < nodeBegin.column);
            });
    }

While converting the source, each comment that is visited calls this method and gives this trace (eol removed):

siblingEnd: (line 1,col 6) - type: com.github.javaparser.ast.Modifier - sibling: public 
siblingEnd: (line 1,col 18) - type: com.github.javaparser.ast.expr.SimpleName - sibling: Child
siblingEnd: (line 3,col 29) - type: com.github.javaparser.ast.body.MethodDeclaration - sibling: //comment 1 public void method1() { }
siblingEnd: (line 5,col 29) - type: com.github.javaparser.ast.body.MethodDeclaration - sibling: //comment 2 public void method1() {}
siblingEnd: (line 7,col 29) - type: com.github.javaparser.ast.body.MethodDeclaration - sibling: //comment 3 public void method1() { }
siblingEnd: (line 1,col 33) - type: com.github.javaparser.ast.type.ClassOrInterfaceType - sibling: Parent

We can see that the last item found is the Parent class that is what our class is extending. As it is at line 1, all comments from line 1 to the current position are placed in the converted code.

I don't understand why the java parser creates the nodes in this order, but there are two options to fix it:

  1. Filter-out the last node (note that Child has a different type as Parent), eg. by adding .Where(sibling => sibling is not com.github.javaparser.ast.type.ClassOrInterfaceType)
  2. Sort all nodes by their position, eg. by adding .OrderBy(sibling => sibling.getEnd().FromOptional<JavaParser.Position>())

Option 1 seems simple, but I'm not sure if it could cause potential side effects. Opion 2 seems safer, although with a little bit more performance impact.

@paulirwin What do you think about that? option 1, 2 or something else?

javiertuya added a commit to javiertuya/JavaToCSharp that referenced this issue Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants