Comments (2)
Which version are you using?
I just tried your text on my PC and it works fine with the latest master branch
Nvm, got it from your backtrace information.
Can you send the raw file because I can't reproduce it if I just copy your text.
from rslint.
This is the full text from the file.
There are three instances of that character and after removing them the parser no longer panics.
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);
});
});
});
});
from rslint.
Related Issues (20)
- Allow linting JS as modules HOT 7
- `ForOfStmt` missing from `ast::Stmt` enum HOT 1
- How to debug in VSCode HOT 6
- WebAssembly! HOT 1
- Logotype
- No binary for v0.3.x release HOT 3
- How can I adjust an AST node? HOT 4
- Default function parameters are incompletely parsed as AssignPattern HOT 1
- Ran `rslint .` in my Projects directory, got an internal linter error HOT 7
- JSX support HOT 4
- Panic in parse_text_lossy
- Panic when using Fixer: assertion failed: `(left == right)` HOT 3
- Internal Linter Error on rslint_parser/src/lossless_tree_sink.rs
- Install error
- docs: http://rslint.org/ is down HOT 2
- 'The parser seems to be recursing forever' at invalid if/else brackets configuration. HOT 1
- Internal error
- How does casting work from untyped nodes to typed nodes when building the linting AST?
- Is this project still under maintenance? HOT 1
- [DOCS] Full file and single statement rslint-ignore statements are identical in documentation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rslint.