本文整理汇总了Java中com.intellij.codeInsight.daemon.impl.ShowAutoImportPass类的典型用法代码示例。如果您正苦于以下问题:Java ShowAutoImportPass类的具体用法?Java ShowAutoImportPass怎么用?Java ShowAutoImportPass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ShowAutoImportPass类属于com.intellij.codeInsight.daemon.impl包,在下文中一共展示了ShowAutoImportPass类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: showHint
import com.intellij.codeInsight.daemon.impl.ShowAutoImportPass; //导入依赖的package包/类
@Override
public boolean showHint(@NotNull Editor editor) {
if (!SchemaSettings.getInstance().SHOW_SCHEMA_ADD_IMPORT_HINTS) return false;
if (typeRef.resolve() != null) return false;
List<String> importOptions = calculateImportOptions();
if (importOptions.isEmpty()) return false;
final String message = ShowAutoImportPass.getMessage(importOptions.size() > 1, importOptions.get(0));
final ImportTypeAction action = new ImportTypeAction((SchemaFile) typeRef.getContainingFile(), importOptions, editor);
HintManager.getInstance().showQuestionHint(editor, message,
typeRef.getTextOffset(),
typeRef.getTextRange().getEndOffset(), action);
return false;
}
开发者ID:SumoLogic,项目名称:epigraph,代码行数:17,代码来源:ImportTypeIntentionFix.java
示例2: showHint
import com.intellij.codeInsight.daemon.impl.ShowAutoImportPass; //导入依赖的package包/类
public boolean showHint(Editor editor) {
if (!PyCodeInsightSettings.getInstance().SHOW_IMPORT_POPUP) {
return false;
}
final PsiElement element = getStartElement();
if (element == null || !element.isValid() || (element instanceof PsiNamedElement && ((PsiNamedElement)element).getName() == null)
|| myImports.size() <= 0) {
return false; // TODO: also return false if an on-the-fly unambiguous fix is possible?
}
if (ImportFromExistingAction.isResolved(myReference)) {
return false;
}
if (HintManager.getInstance().hasShownHintsThatWillHideByOtherHint(true)) {
return false;
}
if ((element instanceof PyQualifiedExpression) && ((((PyQualifiedExpression)element).isQualified()))) return false; // we cannot be qualified
final String message = ShowAutoImportPass.getMessage(
myImports.size() > 1,
ImportCandidateHolder.getQualifiedName(myInitialName, myImports.get(0).getPath(), myImports.get(0).getImportElement())
);
final ImportFromExistingAction action = new ImportFromExistingAction(element, myImports, myInitialName, myUseQualifiedImport, false);
action.onDone(new Runnable() {
public void run() {
myExpended = true;
}
});
HintManager.getInstance().showQuestionHint(
editor, message,
element.getTextOffset(),
element.getTextRange().getEndOffset(), action);
return true;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:AutoImportQuickFix.java
示例3: showHint
import com.intellij.codeInsight.daemon.impl.ShowAutoImportPass; //导入依赖的package包/类
@Override
public boolean showHint(@NotNull final Editor editor) {
XmlToken token = null;
if (myToken != null) {
token = (XmlToken)myToken.retrieve();
if (token == null) return false;
}
if (!XmlSettings.getInstance().SHOW_XML_ADD_IMPORT_HINTS || myNamespacePrefix.isEmpty()) {
return false;
}
final PsiElement element = myElement.retrieve();
if (element == null) return false;
final List<String> namespaces = getNamespaces(element, getFile());
if (!namespaces.isEmpty()) {
final String message = ShowAutoImportPass.getMessage(namespaces.size() > 1, namespaces.iterator().next());
final String title = getTitle();
final ImportNSAction action = new ImportNSAction(namespaces, getFile(), element, editor, title);
if (element instanceof XmlTag && token != null) {
if (VisibleHighlightingPassFactory.calculateVisibleRange(editor).contains(token.getTextRange())) {
HintManager.getInstance().showQuestionHint(editor, message,
token.getTextOffset(),
token.getTextOffset() + myNamespacePrefix.length(), action);
return true;
}
} else {
HintManager.getInstance().showQuestionHint(editor, message,
element.getTextOffset(),
element.getTextRange().getEndOffset(), action);
return true;
}
}
return false;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:CreateNSDeclarationIntentionFix.java
示例4: showHint
import com.intellij.codeInsight.daemon.impl.ShowAutoImportPass; //导入依赖的package包/类
@Override
public boolean showHint(@NotNull final Editor editor) {
if (myToken == null) return false;
XmlToken token = (XmlToken)myToken.retrieve();
if (token == null) return false;
if (!XmlSettings.getInstance().SHOW_XML_ADD_IMPORT_HINTS || myNamespacePrefix.isEmpty()) {
return false;
}
final PsiElement element = myElement.retrieve();
if (element == null) return false;
final Set<String> namespaces = getXmlExtension().guessUnboundNamespaces(element, getFile());
if (!namespaces.isEmpty()) {
final String message = ShowAutoImportPass.getMessage(namespaces.size() > 1, namespaces.iterator().next());
final String title = getTitle();
final ImportNSAction action = new ImportNSAction(namespaces, getFile(), element, editor, title);
if (element instanceof XmlTag) {
if (VisibleHighlightingPassFactory.calculateVisibleRange(editor).contains(token.getTextRange())) {
HintManager.getInstance().showQuestionHint(editor, message,
token.getTextOffset(),
token.getTextOffset() + myNamespacePrefix.length(), action);
return true;
}
} else {
HintManager.getInstance().showQuestionHint(editor, message,
element.getTextOffset(),
element.getTextRange().getEndOffset(), action);
return true;
}
}
return false;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:32,代码来源:CreateNSDeclarationIntentionFix.java
示例5: doFix
import com.intellij.codeInsight.daemon.impl.ShowAutoImportPass; //导入依赖的package包/类
private ImportClassFixBase.Result doFix(Editor editor)
{
if(!CodeInsightSettings.getInstance().ADD_MEMBER_IMPORTS_ON_THE_FLY)
{
return ImportClassFixBase.Result.POPUP_NOT_SHOWN;
}
final List<T> candidates = getMembersToImport(true);
if(candidates.isEmpty())
{
return ImportClassFixBase.Result.POPUP_NOT_SHOWN;
}
final PsiElement element = getElement();
if(element == null)
{
return ImportClassFixBase.Result.POPUP_NOT_SHOWN;
}
final QuestionAction action = createQuestionAction(candidates, element.getProject(), editor);
/* PsiFile psiFile = element.getContainingFile();
if (candidates.size() == 1 &&
ImportClassFixBase.isAddUnambiguousImportsOnTheFlyEnabled(psiFile) &&
(ApplicationManager.getApplication().isUnitTestMode() || DaemonListeners.canChangeFileSilently(psiFile)) &&
!LaterInvocator.isInModalContext()) {
CommandProcessor.getInstance().runUndoTransparentAction(() -> action.execute());
return ImportClassFixBase.Result.CLASS_AUTO_IMPORTED;
}
*/
String hintText = ShowAutoImportPass.getMessage(candidates.size() > 1, getMemberPresentableText(candidates.get(0)));
if(!ApplicationManager.getApplication().isUnitTestMode() && !HintManager.getInstance().hasShownHintsThatWillHideByOtherHint(true))
{
final TextRange textRange = element.getTextRange();
HintManager.getInstance().showQuestionHint(editor, hintText, textRange.getStartOffset(), textRange.getEndOffset(), action);
}
return ImportClassFixBase.Result.POPUP_SHOWN;
}
开发者ID:consulo,项目名称:consulo-java,代码行数:37,代码来源:StaticImportMemberFix.java
示例6: doFix
import com.intellij.codeInsight.daemon.impl.ShowAutoImportPass; //导入依赖的package包/类
public Result doFix(@NotNull final Editor editor, boolean allowPopup, final boolean allowCaretNearRef) {
List<PsiClass> classesToImport = getClassesToImport();
if (classesToImport.isEmpty()) return Result.POPUP_NOT_SHOWN;
try {
String name = getQualifiedName(myElement);
if (name != null) {
Pattern pattern = Pattern.compile(DaemonCodeAnalyzerSettings.getInstance().NO_AUTO_IMPORT_PATTERN);
Matcher matcher = pattern.matcher(name);
if (matcher.matches()) {
return Result.POPUP_NOT_SHOWN;
}
}
}
catch (PatternSyntaxException e) {
//ignore
}
final PsiFile psiFile = myElement.getContainingFile();
if (classesToImport.size() > 1) {
reduceSuggestedClassesBasedOnDependencyRuleViolation(psiFile, classesToImport);
}
PsiClass[] classes = classesToImport.toArray(new PsiClass[classesToImport.size()]);
final Project project = myElement.getProject();
CodeInsightUtil.sortIdenticalShortNameClasses(classes, myRef);
final QuestionAction action = createAddImportAction(classes, project, editor);
boolean canImportHere = true;
if (classes.length == 1
&& (canImportHere = canImportHere(allowCaretNearRef, editor, psiFile, classes[0].getName()))
&& (FileTypeUtils.isInServerPageFile(psiFile) ?
CodeInsightSettings.getInstance().JSP_ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY :
CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY)
&& (ApplicationManager.getApplication().isUnitTestMode() || DaemonListeners.canChangeFileSilently(psiFile))
&& !autoImportWillInsertUnexpectedCharacters(classes[0])
&& !LaterInvocator.isInModalContext()
) {
CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
@Override
public void run() {
action.execute();
}
});
return Result.CLASS_AUTO_IMPORTED;
}
if (allowPopup && canImportHere) {
String hintText = ShowAutoImportPass.getMessage(classes.length > 1, classes[0].getQualifiedName());
if (!ApplicationManager.getApplication().isUnitTestMode() && !HintManager.getInstance().hasShownHintsThatWillHideByOtherHint(true)) {
HintManager.getInstance().showQuestionHint(editor, hintText, getStartOffset(myElement, myRef),
getEndOffset(myElement, myRef), action);
}
return Result.POPUP_SHOWN;
}
return Result.POPUP_NOT_SHOWN;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:58,代码来源:ImportClassFixBase.java
示例7: doFix
import com.intellij.codeInsight.daemon.impl.ShowAutoImportPass; //导入依赖的package包/类
public Result doFix(@NotNull final Editor editor, boolean allowPopup, final boolean allowCaretNearRef) {
List<PsiClass> classesToImport = getClassesToImport();
if (classesToImport.isEmpty()) return Result.POPUP_NOT_SHOWN;
try {
String name = getQualifiedName(myElement);
if (name != null) {
Pattern pattern = Pattern.compile(DaemonCodeAnalyzerSettings.getInstance().NO_AUTO_IMPORT_PATTERN);
Matcher matcher = pattern.matcher(name);
if (matcher.matches()) {
return Result.POPUP_NOT_SHOWN;
}
}
}
catch (PatternSyntaxException e) {
//ignore
}
final PsiFile psiFile = myElement.getContainingFile();
if (classesToImport.size() > 1) {
reduceSuggestedClassesBasedOnDependencyRuleViolation(psiFile, classesToImport);
}
PsiClass[] classes = classesToImport.toArray(new PsiClass[classesToImport.size()]);
final Project project = myElement.getProject();
CodeInsightUtil.sortIdenticalShortNameClasses(classes, myRef);
final QuestionAction action = createAddImportAction(classes, project, editor);
DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(project);
boolean canImportHere = true;
if (classes.length == 1
&& (canImportHere = canImportHere(allowCaretNearRef, editor, psiFile, classes[0].getName()))
&& (JspPsiUtil.isInJspFile(psiFile) ?
CodeInsightSettings.getInstance().JSP_ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY :
CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY)
&& (ApplicationManager.getApplication().isUnitTestMode() || codeAnalyzer.canChangeFileSilently(psiFile))
&& !autoImportWillInsertUnexpectedCharacters(classes[0])
&& !LaterInvocator.isInModalContext()
) {
CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
@Override
public void run() {
action.execute();
}
});
return Result.CLASS_AUTO_IMPORTED;
}
if (allowPopup && canImportHere) {
String hintText = ShowAutoImportPass.getMessage(classes.length > 1, classes[0].getQualifiedName());
if (!ApplicationManager.getApplication().isUnitTestMode() && !HintManager.getInstance().hasShownHintsThatWillHideByOtherHint(true)) {
HintManager.getInstance().showQuestionHint(editor, hintText, getStartOffset(myElement, myRef),
getEndOffset(myElement, myRef), action);
}
return Result.POPUP_SHOWN;
}
return Result.POPUP_NOT_SHOWN;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:60,代码来源:ImportClassFixBase.java
示例8: doFix
import com.intellij.codeInsight.daemon.impl.ShowAutoImportPass; //导入依赖的package包/类
public Result doFix(@NotNull final Editor editor, boolean allowPopup, final boolean allowCaretNearRef)
{
List<PsiClass> classesToImport = getClassesToImport();
if(classesToImport.isEmpty())
{
return Result.POPUP_NOT_SHOWN;
}
try
{
String name = getQualifiedName(myElement);
if(name != null)
{
Pattern pattern = Pattern.compile(DaemonCodeAnalyzerSettings.getInstance().NO_AUTO_IMPORT_PATTERN);
Matcher matcher = pattern.matcher(name);
if(matcher.matches())
{
return Result.POPUP_NOT_SHOWN;
}
}
}
catch(PatternSyntaxException e)
{
//ignore
}
final PsiFile psiFile = myElement.getContainingFile();
if(classesToImport.size() > 1)
{
reduceSuggestedClassesBasedOnDependencyRuleViolation(psiFile, classesToImport);
}
PsiClass[] classes = classesToImport.toArray(new PsiClass[classesToImport.size()]);
final Project project = myElement.getProject();
CodeInsightUtil.sortIdenticalShortNamedMembers(classes, myRef);
final QuestionAction action = createAddImportAction(classes, project, editor);
boolean canImportHere = true;
boolean isInModlessContext = ModalityPerProjectEAPDescriptor.is() ? !LaterInvocator.isInModalContextForProject(editor.getProject()) : !LaterInvocator.isInModalContext();
if(classes.length == 1 && (canImportHere = canImportHere(allowCaretNearRef, editor, psiFile, classes[0].getName())) && isAddUnambiguousImportsOnTheFlyEnabled(psiFile) && (ApplicationManager
.getApplication().isUnitTestMode() || DaemonListeners.canChangeFileSilently(psiFile)) && isInModlessContext && !autoImportWillInsertUnexpectedCharacters(classes[0]))
{
CommandProcessor.getInstance().runUndoTransparentAction(() -> action.execute());
return Result.CLASS_AUTO_IMPORTED;
}
if(allowPopup && canImportHere)
{
String hintText = ShowAutoImportPass.getMessage(classes.length > 1, classes[0].getQualifiedName());
if(!ApplicationManager.getApplication().isUnitTestMode() && !HintManager.getInstance().hasShownHintsThatWillHideByOtherHint(true))
{
HintManager.getInstance().showQuestionHint(editor, hintText, getStartOffset(myElement, myRef), getEndOffset(myElement, myRef), action);
}
return Result.POPUP_SHOWN;
}
return Result.POPUP_NOT_SHOWN;
}
开发者ID:consulo,项目名称:consulo-java,代码行数:59,代码来源:ImportClassFixBase.java
注:本文中的com.intellij.codeInsight.daemon.impl.ShowAutoImportPass类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论