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
rslint_parser panic #118
Comments
Nvm, got it from your backtrace information. |
This is the full text from the file. import Vector2D from 'core/engine/geometry/Vector2D';
import GraphPoint from 'core/plan/room-profile/editor/GraphPoint';
import { Wall } from 'core/plan/room-profile/editor/WallsHandler';
import { RoomProfileEvents } from 'core/plan/room-profile/RoomProfileEvents';
import { SelectedPoint } from 'core/plan/room-profile/editor/ui-modes/MovingMode/InteractableEntities/SelectedEntity';
import MovingMode from 'inject!core/plan/room-profile/editor/ui-modes/MovingMode/MovingMode';
describe('MovingMode', function () {
beforeEach(function () {
this.SelectedEntityFactory = jasmine.createSpyObj('SelectedEntityFactory', ['from']);
this.HoveredEntityFactory = jasmine.createSpyObj('HoveredEntityFactory', ['from']);
this.uiUtils = jasmine.createSpyObj('uiUtils', ['getWallUnderCursor', 'snapToWall']);
this.SelectedEntityFactory.SelectedPoint = SelectedPoint;
this.wallsHandler = jasmine.createSpyObj('wallsHandler', ['getAnchors', 'getWalls']);
this.wallsHandler.getWalls.and.returnValue([]);
this.events = jasmine.createSpyObj('events', ['emit']);
this.auxiliaryPointsHandler = jasmine.createSpy('auxiliaryPointsHandler');
const guideLinesHandler = jasmine.createSpyObj('guideLinesHandler', [
'getClosestGuideLinesIntersection',
'getClosestGuideLines',
'updateClosestGuideLinesForWallPivots',
'updateClosestGuideLines',
]);
guideLinesHandler.getClosestGuideLines.and.callFake(() => []);
const angleService = jasmine.createSpy('angleService');
const roomShapeManipulator = jasmine.createSpyObj('roomShapeManipulator', ['moveAnchorBy']);
const MovingModeConstructor = MovingMode({
'./InteractableEntities/HoveredEntity': this.HoveredEntityFactory,
'./InteractableEntities/SelectedEntity': this.SelectedEntityFactory,
'../uiUtils': this.uiUtils,
'../../../RoomProfileEvents': {
events: this.events,
RoomProfileEvents,
},
}).default;
this.movingMode = new MovingModeConstructor(
this.wallsHandler,
angleService,
this.auxiliaryPointsHandler,
roomShapeManipulator,
guideLinesHandler,
);
});
describe('#handleMouseMove', function () {
beforeEach(function () {
this.event = jasmine.createSpyObj('event', ['preventDefault']);
});
describe('when dragging is in progress', function () {
beforeEach(function () {
spyOn(this.movingMode, 'isInProgress');
this.movingMode.isInProgress.and.returnValue(true);
});
it('prevents default handling for event', function () {
spyOn(this.movingMode, 'handleDrag');
expect(this.event.preventDefault).not.toHaveBeenCalled();
this.movingMode.handleMouseMove(Vector2D.zero, this.event);
expect(this.event.preventDefault).toHaveBeenCalledOnce();
});
});
});
// o - cursor position
// + - anchor position
// ⊕ - cursor over anchor
describe('dragging workflow', function () {
beforeEach(function () {
this.event = jasmine.createSpyObj('event', ['preventDefault']);
this.interactableEntity = jasmine.createSpyObj('interactableEntity', [
'getEntity',
'getAffectedPoints',
'getPosition',
'move',
'destroy',
]);
this.HoveredEntityFactory.from.and.returnValue(this.interactableEntity);
this.SelectedEntityFactory.from.and.returnValue(this.interactableEntity);
});
describe('for anchor', function () {
beforeEach(function () {
this.anchor = new GraphPoint(0, 0);
this.interactableEntity.getEntity.and.returnValue(this.anchor);
this.interactableEntity.getAffectedPoints.and.returnValue([this.anchor]);
this.interactableEntity.getPosition.and.callFake(() => this.anchor.toVector2D());
this.wallsHandler.getAnchors.and.returnValue([this.anchor]);
// NOTE: cursorPosition is slightly shifted from the center of an anchor
const startCursorPosition = this.anchor.toVector2D().add(new Vector2D(1, 1));
this.movingMode.handleMouseMove(startCursorPosition);
this.movingMode.handleMouseDown(startCursorPosition);
});
it('correctly calculates delta for dragged anchor when entity has not been restricted in previous movement step', function () {
let desiredCursorPosition;
// step 1
desiredCursorPosition = new Vector2D(4, 0);
this.movingMode.handleMouseMove(desiredCursorPosition, this.event);
expect(this.interactableEntity.move).toHaveBeenCalledWith(
this.auxiliaryPointsHandler, new Vector2D(3, -1), undefined,
);
// emulate case when anchor is moved to desired position
this.anchor.x = 3;
this.anchor.z = -1;
// step 2
desiredCursorPosition = new Vector2D(0, 3);
this.movingMode.handleMouseMove(desiredCursorPosition, this.event);
expect(this.interactableEntity.move).toHaveBeenCalledWith(
this.auxiliaryPointsHandler, new Vector2D(-4, 3), undefined,
);
});
//
// ⊕ =1> +·o =2>
//
// ⊕
it('correctly calculates delta for dragged anchor when anchor has been restricted in previous movement step', function () {
let desiredCursorPosition;
// step 1
desiredCursorPosition = new Vector2D(4, 1);
this.movingMode.handleMouseMove(desiredCursorPosition, this.event);
expect(this.interactableEntity.move).toHaveBeenCalledWith(
this.auxiliaryPointsHandler, new Vector2D(3, 0), undefined,
);
// emulate case when anchor has been restricted from be moved to desired position
this.anchor.x = 2; // desired is 3
this.anchor.z = 0;
// step 2
desiredCursorPosition = new Vector2D(0, 3);
this.movingMode.handleMouseMove(desiredCursorPosition, this.event);
expect(this.interactableEntity.move).toHaveBeenCalledWith(
this.auxiliaryPointsHandler, new Vector2D(-3, 2), undefined,
);
});
it('emits entityUnselected event on click on void canvas area', function () {
const cursorPosition = new Vector2D(5, 5);
this.movingMode.hoveredEntity = undefined;
this.movingMode.handleMouseDown(cursorPosition, this.event);
expect(this.events.emit).toHaveBeenCalledWith(RoomProfileEvents.entityUnselected);
});
});
describe('for wall', function () {
beforeEach(function () {
this.wallStartPoint = new GraphPoint(1, 1);
this.wallEndPoint = new GraphPoint(1, 3);
this.wall = new Wall(this.wallStartPoint, this.wallEndPoint);
this.interactableEntity.getEntity.and.returnValue(this.wall);
this.interactableEntity.getAffectedPoints.and.returnValue([this.wallStartPoint, this.wallEndPoint]);
this.interactableEntity.getPosition.and.callFake(() => new Vector2D(Math.min(this.wallStartPoint.x, this.wallEndPoint.x), Math.min(this.wallStartPoint.z, this.wallEndPoint.z)));
this.wallsHandler.getAnchors.and.returnValue([this.wallStartPoint, this.wallEndPoint]);
this.uiUtils.getWallUnderCursor.and.returnValue(this.wall);
const startCursorPosition = new Vector2D(1, 2);
this.movingMode.handleMouseMove(startCursorPosition);
this.movingMode.handleMouseDown(startCursorPosition);
});
// +
// |
// + o
// | | +
// o =1> + =2> |
// | o
// + |
// +
it('correctly calculates delta for dragged wall when wall has not been restricted in previous movement step', function () {
let desiredCursorPosition;
// step 1
desiredCursorPosition = new Vector2D(2, 0);
this.movingMode.handleMouseMove(desiredCursorPosition, this.event);
expect(this.interactableEntity.move).toHaveBeenCalledWith(
this.auxiliaryPointsHandler, new Vector2D(1, -2), undefined,
);
// emulate case when wall is moved to desired position
this.wallStartPoint.x = 2;
this.wallStartPoint.z = -1;
this.wallEndPoint.x = 2;
this.wallEndPoint.z = 1;
// step 2
desiredCursorPosition = new Vector2D(-2, 2);
this.movingMode.handleMouseMove(desiredCursorPosition, this.event);
expect(this.interactableEntity.move).toHaveBeenCalledWith(
this.auxiliaryPointsHandler, new Vector2D(-4, 2), undefined,
);
});
// +
// |
// + + o
// | | + |
// o =1> |··o =2> | =3> +
// | | |
// + + |
// +
// ·
// o
it('correctly calculates delta for dragged wall when wall has been restricted in previous movement step', function () {
let desiredCursorPosition;
// step 1
desiredCursorPosition = new Vector2D(4, 2);
this.movingMode.handleMouseMove(desiredCursorPosition, this.event);
expect(this.interactableEntity.move).toHaveBeenCalledWith(
this.auxiliaryPointsHandler, new Vector2D(3, 0), undefined,
);
// emulate case when anchor has been restricted from be moved to desired position
this.wallStartPoint.x = 3; // desired is 4
this.wallStartPoint.z = 1;
this.wallEndPoint.x = 3; // desired is 4
this.wallEndPoint.z = 3;
// step 2
desiredCursorPosition = new Vector2D(0, 3);
this.movingMode.handleMouseMove(desiredCursorPosition, this.event);
expect(this.interactableEntity.move).toHaveBeenCalledWith(
this.auxiliaryPointsHandler, new Vector2D(-3, 1), undefined,
);
});
it('emits entityUnselected event on click on void canvas area', function () {
const cursorPosition = new Vector2D(5, 5);
this.movingMode.hoveredEntity = undefined;
this.movingMode.handleMouseDown(cursorPosition, this.event);
expect(this.events.emit).toHaveBeenCalledWith(RoomProfileEvents.entityUnselected);
});
});
});
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tried this code:
// ⊕
I expected this to happen:
The parser should not crash
Instead this happened::
Meta
rslint -V
:If building from source:
rustc --version --verbose
:Additional context
I am using
rslint_parser
as a library in a tool I am writing and it failed to parse one of our files. After looking through the file for a while I noticed the above symbol in a comment. After removing it the parser succeeds.I'm using a forked version of rslint, but I thought I'd raise an issue for this here anyway. I only created the fork a week or so ago anyway.
The text was updated successfully, but these errors were encountered: