forked from bazelbuild/intellij
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
131 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
61 changes: 61 additions & 0 deletions
61
base/src/com/google/idea/blaze/base/lang/buildfile/completion/WorkspaceLookupElement.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,61 @@ | ||
package com.google.idea.blaze.base.lang.buildfile.completion; | ||
|
||
import com.google.idea.blaze.base.lang.buildfile.references.QuoteType; | ||
import com.google.idea.blaze.base.model.primitives.ExternalWorkspace; | ||
import com.intellij.codeInsight.completion.InsertionContext; | ||
import com.intellij.codeInsight.lookup.AutoCompletionPolicy; | ||
import com.intellij.codeInsight.lookup.Lookup; | ||
import com.intellij.util.PlatformIcons; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import javax.swing.*; | ||
|
||
public class WorkspaceLookupElement extends BuildLookupElement { | ||
|
||
final ExternalWorkspace workspace; | ||
public WorkspaceLookupElement(ExternalWorkspace workspace) { | ||
super(workspace.repoName(), QuoteType.NoQuotes); | ||
this.workspace = workspace; | ||
} | ||
|
||
@Override | ||
public String getLookupString() { | ||
if (workspace.repoName() == null || workspace.repoName().isEmpty()) { | ||
return "@" + workspace.name(); | ||
} | ||
|
||
return "@" + workspace.repoName(); | ||
} | ||
|
||
@Override | ||
protected @Nullable String getTypeText() { | ||
return workspace.name(); | ||
} | ||
|
||
@Override | ||
protected @Nullable String getTailText() { | ||
return "//"; | ||
} | ||
|
||
@Override | ||
public @Nullable Icon getIcon() { | ||
return PlatformIcons.IMPORT_ICON; | ||
} | ||
|
||
protected String getItemText() { | ||
if (workspace.repoName() == null || workspace.repoName().isEmpty()) { | ||
return "@" + workspace.name(); | ||
} | ||
|
||
return "@" + workspace.repoName(); | ||
} | ||
|
||
@Override | ||
public void handleInsert(InsertionContext context) { | ||
switch (context.getCompletionChar()) { | ||
case Lookup.REPLACE_SELECT_CHAR: | ||
case Lookup.NORMAL_SELECT_CHAR: | ||
} | ||
super.handleInsert(context); | ||
} | ||
} |
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