-
Notifications
You must be signed in to change notification settings - Fork 71
Fixes #340 #341
Fixes #340 #341
Changes from all commits
383d8d6
d6cbb16
4137686
2084874
e55b1e2
beac08a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| /* | ||
| * Copyright 2017 Palantir Technologies, Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package com.palantir.typescript.services.language; | ||
|
|
||
| import static com.google.common.base.Preconditions.checkNotNull; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import com.google.common.base.Objects; | ||
| import com.google.common.base.StandardSystemProperty; | ||
|
|
||
| /** | ||
| * Corresponds to the class with the same name in TypeScript. | ||
| * | ||
| * @author Rouche | ||
| */ | ||
| public final class JSDocTagInfo { | ||
|
|
||
| private final String name; | ||
| private final String text; | ||
|
|
||
| public JSDocTagInfo( | ||
| @JsonProperty("name") String name, | ||
| @JsonProperty("text") String text) { | ||
| checkNotNull(name); | ||
|
|
||
| this.name = name; | ||
| this.text = text; | ||
| } | ||
|
|
||
| public String getName() { | ||
| return this.name; | ||
| } | ||
|
|
||
| public String getText() { | ||
| return this.text; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return Objects.toStringHelper(this) | ||
| .add("name", this.name) | ||
| .add("text", this.text) | ||
| .toString(); | ||
| } | ||
|
|
||
| public static String getText(List<JSDocTagInfo> parts) { | ||
| checkNotNull(parts); | ||
|
|
||
| StringBuilder displayText = new StringBuilder(); | ||
|
|
||
| for (JSDocTagInfo part : parts) { | ||
| displayText.append(part.getName()); | ||
| if(part.getText() != null && part.getText().trim().length() > 0) { | ||
| displayText.append(" "); | ||
| displayText.append(part.getText()); | ||
| } | ||
| displayText.append(StandardSystemProperty.LINE_SEPARATOR.value()); | ||
| } | ||
|
|
||
| return displayText.toString(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -118,17 +118,22 @@ public IPresentationRepairer getRepairer(String contentType) { | |
| */ | ||
| private void processEvent(TextEvent event) { | ||
| IRegion damagedRegion = this.getDamagedRegion(event); | ||
| EndOfLineState lastDamagedLexState = this.updateFinalLexStates(event, damagedRegion); | ||
| TextPresentation presentation = this.createPresentation(damagedRegion, lastDamagedLexState); | ||
| if(damagedRegion != null) { | ||
| EndOfLineState lastDamagedLexState = this.updateFinalLexStates(event, damagedRegion); | ||
| TextPresentation presentation = this.createPresentation(damagedRegion, lastDamagedLexState); | ||
|
|
||
| this.viewer.changeTextPresentation(presentation, false); | ||
| this.viewer.changeTextPresentation(presentation, false); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Gets the damaged region by selecting the whole lines touched by the text edit. | ||
| */ | ||
| private IRegion getDamagedRegion(TextEvent event) { | ||
| IDocument document = this.viewer.getDocument(); | ||
| if(document == null) { | ||
| return null; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor preference on using optional instead
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gonna have to fill me in on this one. Been in TypeScript last year rusted my reflexes :P
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. something like it's preferred so that the caller would know that the value might not be present, so it can do it doesnt seem like anywhere else is using this pattern though so fine to keep it as it is for code consistency too
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok i see. Well, you know Optional is JDK 1.8, the plugin right now is still JDK 1.6, until i commit my update of Tycko to 0.26.0, wich is pending on this merge :) This one is a lot more important.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. guava's be fine (thats what everyone uses before JDK 1.8), but yea not really important :P |
||
| } | ||
| int documentLength = document.getLength(); | ||
| int offset = event.getOffset(); | ||
| int length = event.getLength(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
never use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was unsure if you want to add the text in the Over. At least the method is there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by "Over" you mean "Overview"?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops... i mean the Hover lol. The popup that appear on Hovering. This method would have to be used to fill it with more info.
Sorry.