Skip to content

fix the NPE in DocumentSymbolHandler when source/location is not avai…#851

Closed
andxu wants to merge 2 commits intoeclipse-jdtls:masterfrom
andxu:andy_fix1
Closed

fix the NPE in DocumentSymbolHandler when source/location is not avai…#851
andxu wants to merge 2 commits intoeclipse-jdtls:masterfrom
andxu:andy_fix1

Conversation

@andxu
Copy link
Contributor

@andxu andxu commented Nov 15, 2018

…lable.

Signed-off-by: andxu <andxu@microsoft.com>
@eclipse-ls-bot
Copy link
Contributor

Can one of the admins verify this patch?

@yaohaizh
Copy link
Contributor

@fbricon Why sometimes the CI doesn't work?

@fbricon
Copy link
Contributor

fbricon commented Nov 15, 2018

add to whitelist

@fbricon
Copy link
Contributor

fbricon commented Nov 15, 2018

@yaohaizh only PRs from trusted contributors are run built automatically. See my previous comment to make Jenkins trust the author of the PR

return JDTUtils.toLocation(element).getRange();
Location location = JDTUtils.toLocation(element, FULL_RANGE);
return location == null ? DEFAULT_RANGE : location.getRange();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getRange and getSelectionRange are now strictly identical O_o

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove the call of "toLocation" twice to share the location? I don't know why the original purpose of SelectionRange and getRange

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 on removing that. It was implemented according to the spec:

/**
* The range enclosing this symbol not including leading/trailing whitespace but everything else
* like comments. This information is typically used to determine if the clients cursor is
* inside the symbol to reveal in the symbol in the UI.
*/
range: Range;

/**
* The range that should be selected and revealed when this symbol is being picked, e.g the name of a function.
* Must be contained by the range.
*/
selectionRange: Range;

You might break other clients by changing those ranges


private Range getSelectionRange(IJavaElement element) throws JavaModelException {
return JDTUtils.toLocation(element).getRange();
Location location = JDTUtils.toLocation(element, FULL_RANGE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Location location = JDTUtils.toLocation(element);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

…ch includes the comment)

Signed-off-by: andxu <andxu@microsoft.com>
@andxu
Copy link
Contributor Author

andxu commented Nov 16, 2018

I cannot run any mvn related targets on jdt.ls now:

image

@fbricon
Copy link
Contributor

fbricon commented Nov 16, 2018

Fixed with 2e0d78e

I restored the range and selectionrange calls

@fbricon fbricon closed this Nov 16, 2018
@andxu andxu deleted the andy_fix1 branch November 18, 2018 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants