-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1801 implement 'Signature Help' LS feature
- Loading branch information
Evgen Vidolob
committed
Sep 29, 2016
1 parent
6e3aa1c
commit a0f374e
Showing
37 changed files
with
1,268 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...he-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/signature/ParameterInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012-2016 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.che.ide.api.editor.signature; | ||
|
||
import com.google.common.base.Optional; | ||
|
||
import javax.validation.constraints.NotNull; | ||
|
||
/** | ||
* Represent a parameter of callable signature. | ||
* Parameter can have label and optional documentation. | ||
* | ||
* @author Evgen Vidolob | ||
*/ | ||
public interface ParameterInfo { | ||
|
||
/** | ||
* The label of this parameter. Used for UI. | ||
* @return the parameter label. | ||
*/ | ||
@NotNull | ||
String getLabel(); | ||
|
||
/** | ||
* The documentation of this parameter. | ||
* @return the human-readable documentation string. | ||
*/ | ||
Optional<String> getDocumentation(); | ||
} |
44 changes: 44 additions & 0 deletions
44
...he-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/signature/SignatureHelp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012-2016 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.che.ide.api.editor.signature; | ||
|
||
import com.google.common.base.Optional; | ||
|
||
import javax.validation.constraints.NotNull; | ||
import java.util.List; | ||
|
||
/** | ||
* Result of calculation of signatures, represent the signature of something callable. | ||
* | ||
* @author Evgen Vidolob | ||
*/ | ||
public interface SignatureHelp { | ||
|
||
/** | ||
* One or more signature. | ||
* @return | ||
*/ | ||
@NotNull | ||
List<SignatureInfo> getSignatures(); | ||
|
||
/** | ||
* The active signature | ||
* | ||
* @return | ||
*/ | ||
Optional<Integer> getActiveSignature(); | ||
|
||
/** | ||
* The active parameter of the active signature. | ||
* @return | ||
*/ | ||
Optional<Integer> getActiveParameter(); | ||
} |
48 changes: 48 additions & 0 deletions
48
...ide-api/src/main/java/org/eclipse/che/ide/api/editor/signature/SignatureHelpProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012-2016 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.che.ide.api.editor.signature; | ||
|
||
import com.google.common.base.Optional; | ||
|
||
import org.eclipse.che.api.promises.client.Promise; | ||
import org.eclipse.che.ide.api.editor.document.Document; | ||
import org.eclipse.che.ide.api.editor.texteditor.TextEditor; | ||
|
||
import javax.validation.constraints.NotNull; | ||
|
||
/** | ||
* Calculates signature information at cursor position. | ||
* | ||
* @author Evgen Vidolob | ||
*/ | ||
public interface SignatureHelpProvider { | ||
|
||
/** | ||
* Requests to provide signature information | ||
* @param document | ||
* the document where request called | ||
* @param offset | ||
* the offset where request called | ||
* @return the promise. | ||
*/ | ||
@NotNull | ||
Promise<Optional<SignatureHelp>> signatureHelp(Document document, int offset); | ||
|
||
/** | ||
* Installs the SignatureHelpProvider on the given text view. | ||
*/ | ||
void install(TextEditor editor); | ||
|
||
/** | ||
* Removes the SignatureHelpProvider from the text view it has previously been installed on. | ||
*/ | ||
void uninstall(); | ||
} |
43 changes: 43 additions & 0 deletions
43
...he-core-ide-api/src/main/java/org/eclipse/che/ide/api/editor/signature/SignatureInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012-2016 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.che.ide.api.editor.signature; | ||
|
||
import com.google.common.base.Optional; | ||
|
||
import javax.validation.constraints.NotNull; | ||
import java.util.List; | ||
|
||
/** | ||
* Represents the signature of something callable. A signature can have label, like method name, | ||
* a documentation and list of parameters | ||
* | ||
* @author Evgen Vidolob | ||
*/ | ||
public interface SignatureInfo { | ||
/** | ||
* The label of this signature. | ||
* @return | ||
*/ | ||
@NotNull | ||
String getLabel(); | ||
|
||
/** | ||
* The documentation of this signature | ||
* @return | ||
*/ | ||
Optional<String> getDocumentation(); | ||
|
||
/** | ||
* The parameters of this signature. | ||
* @return | ||
*/ | ||
Optional<List<ParameterInfo>> getParameters(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/actions/SignatureHelpAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012-2016 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.che.ide.actions; | ||
|
||
import com.google.inject.Inject; | ||
import com.google.inject.Singleton; | ||
|
||
import org.eclipse.che.ide.CoreLocalizationConstant; | ||
import org.eclipse.che.ide.api.action.AbstractPerspectiveAction; | ||
import org.eclipse.che.ide.api.action.ActionEvent; | ||
import org.eclipse.che.ide.api.editor.EditorAgent; | ||
import org.eclipse.che.ide.api.editor.EditorPartPresenter; | ||
import org.eclipse.che.ide.api.editor.texteditor.HandlesTextOperations; | ||
import org.eclipse.che.ide.api.editor.texteditor.TextEditorOperations; | ||
|
||
import javax.validation.constraints.NotNull; | ||
|
||
import static java.util.Collections.singletonList; | ||
import static org.eclipse.che.ide.workspace.perspectives.project.ProjectPerspective.PROJECT_PERSPECTIVE_ID; | ||
|
||
/** | ||
* Action for 'Signature help', in general should show signature of something callable. | ||
* | ||
* @author Evgen Vidolob | ||
*/ | ||
@Singleton | ||
public class SignatureHelpAction extends AbstractPerspectiveAction { | ||
|
||
private final EditorAgent editorAgent; | ||
|
||
@Inject | ||
public SignatureHelpAction(EditorAgent editorAgent, CoreLocalizationConstant constant) { | ||
super(singletonList(PROJECT_PERSPECTIVE_ID), constant.signatureName(), constant.signatureDescription(), null, null); | ||
this.editorAgent = editorAgent; | ||
} | ||
|
||
@Override | ||
public void updateInPerspective(@NotNull ActionEvent event) { | ||
final EditorPartPresenter editor = editorAgent.getActiveEditor(); | ||
boolean isCanDoOperation = false; | ||
|
||
HandlesTextOperations handlesOperations; | ||
if (editor instanceof HandlesTextOperations) { | ||
handlesOperations = (HandlesTextOperations)editor; | ||
isCanDoOperation = handlesOperations.canDoOperation(TextEditorOperations.SIGNATURE_HELP); | ||
} | ||
|
||
event.getPresentation().setEnabledAndVisible(isCanDoOperation); | ||
} | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
final EditorPartPresenter editor = editorAgent.getActiveEditor(); | ||
HandlesTextOperations handlesOperations; | ||
if (editor instanceof HandlesTextOperations) { | ||
handlesOperations = (HandlesTextOperations)editor; | ||
if (handlesOperations.canDoOperation(TextEditorOperations.SIGNATURE_HELP)) { | ||
handlesOperations.doOperation(TextEditorOperations.SIGNATURE_HELP); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.