jakob101 / RelativePathRefactor

A plugin for VSCode
https://marketplace.visualstudio.com/items?itemName=jakob101.relativepathrefactor
5 stars 1 forks source link

Some paths skipped #2

Open ReDrUm opened 7 years ago

ReDrUm commented 7 years ago

Some import statements are incorrectly skipped when fixing relative paths.

Example 1: Before (back two directories):

import { connect } from 'react-redux';
import { memberA } from '../../shared/app/someUtil';
import { memberB, memberC } from '../../shared/account/someWorkflow';
import { memberD } from '../../shared/app/anotherWorkflow';

Example 1: After (back three directories):

import { connect } from 'react-redux';
import { memberA } from "../../../shared/app/localeUtil"; // updated
import { memberB, memberC } from '../../shared/account/someWorkflow'; // skipped
import { memberD } from '../../shared/app/anotherWorkflow'; // skipped

Example 2: Before (back two directories):

import { Link } from 'react-router';
import { memberA, memberB } from '../../shared/util/images';
import Image from '../../shared/component/Image';
import * as classnames from 'classnames';

Example 2: After (back three directories):

import { Link } from 'react-router';
import { memberA, memberB } from '../../shared/util/images'; // skipped
import Image from "../../../shared/component/Image"; // updated
import * as classnames from 'classnames';

This problem occurs throughout several of my project's files. It seems to occur for both single member and multiple member imports.

Interestingly it seems to struggle with imports with multiple members within a single line, but succeeds if they're split e.g.


import { memberA, memberB } from '../../shared/util/images'; // skipped
import {
    memberC,
    memberD,
    memberE,
} from '../../../shared/account/someUtil'; // updated
jakob101 commented 7 years ago

Thanks! Will take a look.

beeplin commented 7 years ago

any progress on this? thanks~!

jakob101 commented 7 years ago

Hey, missed this. I'll take s look.

On Mon, Mar 6, 2017 at 5:09 AM +0100, "Beep LIN" notifications@github.com wrote:

any progress on this? thanks~!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

jakob101 commented 7 years ago

Hey beeplin!

Do you have multiple files with the same name in different folders? Example:

import { memberA, memberB } from '../../shared/util/images'; // skipped

If you had images.js in multiple different folders, the parser will intentionally skip it because it can't figure out which exactly file you need.

Let me know. It's gonna be tricky to handle different edge cases :)