本文整理汇总了Java中com.intellij.featureStatistics.FeatureUsageTracker类的典型用法代码示例。如果您正苦于以下问题:Java FeatureUsageTracker类的具体用法?Java FeatureUsageTracker怎么用?Java FeatureUsageTracker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FeatureUsageTracker类属于com.intellij.featureStatistics包,在下文中一共展示了FeatureUsageTracker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createLookupElement
import com.intellij.featureStatistics.FeatureUsageTracker; //导入依赖的package包/类
@NotNull
@Override
protected LookupElement createLookupElement(@NotNull PsiMember member, @NotNull final PsiClass containingClass, boolean shouldImport) {
shouldImport |= myOriginalPosition != null && PsiTreeUtil.isAncestor(containingClass, myOriginalPosition, false);
if (member instanceof PsiMethod) {
return AutoCompletionPolicy.NEVER_AUTOCOMPLETE.applyPolicy(new GlobalMethodCallElement((PsiMethod)member, shouldImport, false));
}
return AutoCompletionPolicy.NEVER_AUTOCOMPLETE.applyPolicy(new VariableLookupItem((PsiField)member, shouldImport) {
@Override
public void handleInsert(InsertionContext context) {
FeatureUsageTracker.getInstance().triggerFeatureUsed(JavaCompletionFeatures.GLOBAL_MEMBER_NAME);
super.handleInsert(context);
}
});
}
示例2: addArrayMemberAccessors
import com.intellij.featureStatistics.FeatureUsageTracker; //导入依赖的package包/类
private static void addArrayMemberAccessors(final PsiElement element, final String prefix, final PsiType itemType,
final PsiElement qualifier, final Consumer<LookupElement> result, PsiModifierListOwner object,
final PsiType expectedType)
throws IncorrectOperationException {
if (itemType instanceof PsiArrayType && expectedType.isAssignableFrom(((PsiArrayType)itemType).getComponentType())) {
final PsiExpression conversion = createExpression(getQualifierText(qualifier) + prefix + "[0]", element);
result.consume(new ExpressionLookupItem(conversion, object.getIcon(Iconable.ICON_FLAG_VISIBILITY), prefix + "[...]", prefix) {
@Override
public void handleInsert(InsertionContext context) {
FeatureUsageTracker.getInstance().triggerFeatureUsed(JavaCompletionFeatures.SECOND_SMART_COMPLETION_ARRAY_MEMBER);
final int tailOffset = context.getTailOffset();
final String callSpace = getSpace(CodeStyleSettingsManager.getSettings(element.getProject()).SPACE_WITHIN_BRACKETS);
context.getDocument().insertString(tailOffset, "[" + callSpace + callSpace + "]");
context.getEditor().getCaretModel().moveToOffset(tailOffset + 1 + callSpace.length());
}
});
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ReferenceExpressionCompletionContributor.java
示例3: addChainedCallVariants
import com.intellij.featureStatistics.FeatureUsageTracker; //导入依赖的package包/类
private static void addChainedCallVariants(final PsiElement place, LookupElement qualifierItem,
final Consumer<LookupElement> result,
PsiType qualifierType,
final PsiType expectedType, JavaSmartCompletionParameters parameters) throws IncorrectOperationException {
final PsiReferenceExpression mockRef = createMockReference(place, qualifierType, qualifierItem);
if (mockRef == null) {
return;
}
final ElementFilter filter = getReferenceFilter(place, true);
for (final LookupElement item : completeFinalReference(place, mockRef, filter, parameters)) {
if (shouldChain(place, qualifierType, expectedType, item)) {
result.consume(new JavaChainLookupElement(qualifierItem, item) {
@Override
public void handleInsert(InsertionContext context) {
FeatureUsageTracker.getInstance().triggerFeatureUsed(JavaCompletionFeatures.SECOND_SMART_COMPLETION_CHAIN);
super.handleInsert(context);
}
});
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ReferenceExpressionCompletionContributor.java
示例4: addToArrayConversion
import com.intellij.featureStatistics.FeatureUsageTracker; //导入依赖的package包/类
private static void addToArrayConversion(final PsiElement element, final String prefix, @NonNls final String expressionString, @NonNls String presentableString, final Consumer<LookupElement> result, PsiElement qualifier) {
final boolean callSpace = CodeStyleSettingsManager.getSettings(element.getProject()).SPACE_WITHIN_METHOD_CALL_PARENTHESES;
final PsiExpression conversion;
try {
conversion = createExpression(
getQualifierText(qualifier) + prefix + ".toArray(" + getSpace(callSpace) + expressionString + getSpace(callSpace) + ")", element);
}
catch (IncorrectOperationException e) {
return;
}
String[] lookupStrings = {prefix + ".toArray(" + getSpace(callSpace) + expressionString + getSpace(callSpace) + ")", presentableString};
result.consume(new ExpressionLookupItem(conversion, PlatformIcons.METHOD_ICON, prefix + ".toArray(" + presentableString + ")", lookupStrings) {
@Override
public void handleInsert(InsertionContext context) {
FeatureUsageTracker.getInstance().triggerFeatureUsed(JavaCompletionFeatures.SECOND_SMART_COMPLETION_TOAR);
context.commitDocument();
JavaCodeStyleManager.getInstance(context.getProject()).shortenClassReferences(context.getFile(), context.getStartOffset(), context.getTailOffset());
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ReferenceExpressionCompletionContributor.java
示例5: tryToMove
import com.intellij.featureStatistics.FeatureUsageTracker; //导入依赖的package包/类
public boolean tryToMove(final PsiElement element, final Project project, final DataContext dataContext, final PsiReference reference,
final Editor editor) {
if (isStaticInnerClass(element) && !JavaMoveClassesOrPackagesHandler.isReferenceInAnonymousClass(reference)) {
FeatureUsageTracker.getInstance().triggerFeatureUsed("refactoring.move.moveInner");
final PsiElement targetContainer = LangDataKeys.TARGET_PSI_ELEMENT.getData(dataContext);
PsiClass aClass = (PsiClass)element;
SelectInnerOrMembersRefactoringDialog dialog = new SelectInnerOrMembersRefactoringDialog(aClass, project);
if (dialog.showAndGet()) {
final MoveHandlerDelegate moveHandlerDelegate = dialog.getRefactoringHandler();
if (moveHandlerDelegate != null) {
moveHandlerDelegate.doMove(project, new PsiElement[]{aClass}, targetContainer, null);
}
}
return true;
}
return false;
}
示例6: tryToMove
import com.intellij.featureStatistics.FeatureUsageTracker; //导入依赖的package包/类
public boolean tryToMove(final PsiElement element, final Project project, final DataContext dataContext, final PsiReference reference,
final Editor editor) {
if (isNonStaticInnerClass(element) && !JavaMoveClassesOrPackagesHandler.isReferenceInAnonymousClass(reference)) {
PsiClass aClass = (PsiClass) element;
FeatureUsageTracker.getInstance().triggerFeatureUsed("refactoring.move.moveInner");
final PsiClass containingClass = aClass.getContainingClass();
if (containingClass instanceof JspClass) {
CommonRefactoringUtil.showErrorHint(project, editor, RefactoringBundle.message("move.nonstatic.class.from.jsp.not.supported"),
RefactoringBundle.message("move.title"), null);
return true;
}
MoveInnerImpl.doMove(project, new PsiElement[]{aClass}, null, LangDataKeys.TARGET_PSI_ELEMENT.getData(dataContext));
return true;
}
return false;
}
示例7: doClone
import com.intellij.featureStatistics.FeatureUsageTracker; //导入依赖的package包/类
public void doClone(PsiElement element) {
FeatureUsageTracker.getInstance().triggerFeatureUsed("refactoring.copyClass");
PsiClass[] classes = getTopLevelClasses(element);
if (classes == null) {
CopyFilesOrDirectoriesHandler.doCloneFile(element);
return;
}
Project project = element.getProject();
CopyClassDialog dialog = new CopyClassDialog(classes[0], null, project, true);
dialog.setTitle(RefactoringBundle.message("copy.handler.clone.class"));
if (dialog.showAndGet()) {
String className = dialog.getClassName();
PsiDirectory targetDirectory = element.getContainingFile().getContainingDirectory();
copyClassesImpl(className, project, Collections.singletonMap(classes[0].getContainingFile(), classes), null, targetDirectory,
targetDirectory, RefactoringBundle.message("copy.handler.clone.class"), true, true);
}
}
示例8: actionPerformed
import com.intellij.featureStatistics.FeatureUsageTracker; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
DataContext dataContext = e.getDataContext();
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
final Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
final PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
if (project != null && editor != null) {
FeatureUsageTracker.getInstance().triggerFeatureUsed(CODEASSISTS_QUICKJAVADOC_FEATURE);
final LookupImpl lookup = (LookupImpl)LookupManager.getInstance(project).getActiveLookup();
if (lookup != null) {
//dumpLookupElementWeights(lookup);
FeatureUsageTracker.getInstance().triggerFeatureUsed(CODEASSISTS_QUICKJAVADOC_LOOKUP_FEATURE);
}
actionPerformedImpl(project, editor);
}
else if (project != null && element != null) {
FeatureUsageTracker.getInstance().triggerFeatureUsed(CODEASSISTS_QUICKJAVADOC_CTRLN_FEATURE);
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
@Override
public void run() {
DocumentationManager.getInstance(project).showJavaDocInfo(element, null);
}
}, getCommandName(), null);
}
}
示例9: lookupItemSelected
import com.intellij.featureStatistics.FeatureUsageTracker; //导入依赖的package包/类
protected void lookupItemSelected(final CompletionProgressIndicator indicator, @NotNull final LookupElement item, final char completionChar,
final List<LookupElement> items) {
if (indicator.isAutopopupCompletion()) {
FeatureUsageTracker.getInstance().triggerFeatureUsed(CodeCompletionFeatures.EDITING_COMPLETION_BASIC);
}
CompletionAssertions.WatchingInsertionContext context = null;
try {
Lookup lookup = indicator.getLookup();
CompletionLookupArranger.StatisticsUpdate update = CompletionLookupArranger.collectStatisticChanges(item, lookup);
context = insertItemHonorBlockSelection(indicator, item, completionChar, items, update);
CompletionLookupArranger.trackStatistics(context, update);
}
finally {
afterItemInsertion(indicator, context == null ? null : context.getLaterRunnable());
}
}
示例10: execute
import com.intellij.featureStatistics.FeatureUsageTracker; //导入依赖的package包/类
@Override
public void execute(@NotNull final Editor editor, final DataContext dataContext) {
final LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(editor);
if (lookup == null) {
throw new AssertionError("The last lookup disposed at: " + LookupImpl.getLastLookupDisposeTrace() + "\n-----------------------\n");
}
if (finishingChar == Lookup.NORMAL_SELECT_CHAR) {
if (!lookup.isFocused()) {
FeatureUsageTracker.getInstance().triggerFeatureUsed(CodeCompletionFeatures.EDITING_COMPLETION_CONTROL_ENTER);
}
} else if (finishingChar == Lookup.COMPLETE_STATEMENT_SELECT_CHAR) {
FeatureUsageTracker.getInstance().triggerFeatureUsed(CodeCompletionFeatures.EDITING_COMPLETION_FINISH_BY_SMART_ENTER);
} else if (finishingChar == Lookup.REPLACE_SELECT_CHAR) {
FeatureUsageTracker.getInstance().triggerFeatureUsed(CodeCompletionFeatures.EDITING_COMPLETION_REPLACE);
} else if (finishingChar == '.') {
FeatureUsageTracker.getInstance().triggerFeatureUsed(CodeCompletionFeatures.EDITING_COMPLETION_FINISH_BY_CONTROL_DOT);
}
lookup.finishLookup(finishingChar);
}
示例11: gotoActionPerformed
import com.intellij.featureStatistics.FeatureUsageTracker; //导入依赖的package包/类
@Override
public void gotoActionPerformed(@NotNull final AnActionEvent e) {
final Project project = e.getData(CommonDataKeys.PROJECT);
final Component component = e.getData(PlatformDataKeys.CONTEXT_COMPONENT);
Editor editor = e.getData(CommonDataKeys.EDITOR);
PsiFile file = e.getData(CommonDataKeys.PSI_FILE);
FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.popup.action");
GotoActionModel model = new GotoActionModel(project, component, editor, file);
GotoActionCallback<Object> callback = new GotoActionCallback<Object>() {
@Override
public void elementChosen(@NotNull ChooseByNamePopup popup, @NotNull Object element) {
String enteredText = popup.getTrimmedText();
openOptionOrPerformAction(((GotoActionModel.MatchedValue)element).value, enteredText, project, component, e);
}
};
Pair<String, Integer> start = getInitialText(false, e);
showNavigationPopup(callback, null, createPopup(project, model, start.first, start.second, component, e), false);
}
示例12: invoke
import com.intellij.featureStatistics.FeatureUsageTracker; //导入依赖的package包/类
public static void invoke(PsiElement element, Project project, PsiElement nameSuggestionContext, @Nullable Editor editor) {
if (element != null && !canRename(project, editor, element)) {
return;
}
VirtualFile contextFile = PsiUtilCore.getVirtualFile(nameSuggestionContext);
if (nameSuggestionContext != null &&
nameSuggestionContext.isPhysical() &&
(contextFile == null || contextFile.getFileType() != ScratchFileType.INSTANCE) &&
!PsiManager.getInstance(project).isInProject(nameSuggestionContext)) {
final String message = "Selected element is used from non-project files. These usages won't be renamed. Proceed anyway?";
if (ApplicationManager.getApplication().isUnitTestMode()) throw new CommonRefactoringUtil.RefactoringErrorHintException(message);
if (Messages.showYesNoDialog(project, message,
RefactoringBundle.getCannotRefactorMessage(null), Messages.getWarningIcon()) != Messages.YES) {
return;
}
}
FeatureUsageTracker.getInstance().triggerFeatureUsed("refactoring.rename");
rename(element, project, nameSuggestionContext, editor);
}
示例13: process
import com.intellij.featureStatistics.FeatureUsageTracker; //导入依赖的package包/类
@Override
public boolean process(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile psiFile) {
FeatureUsageTracker.getInstance().triggerFeatureUsed("codeassists.complete.statement");
final Document document = editor.getDocument();
final String textForRollback = document.getText();
try {
editor.putUserData(SMART_ENTER_TIMESTAMP, editor.getDocument().getModificationStamp());
myFirstErrorOffset = Integer.MAX_VALUE;
mySkipEnter = false;
process(project, editor, psiFile, 0);
}
catch (TooManyAttemptsException e) {
document.replaceString(0, document.getTextLength(), textForRollback);
} finally {
editor.putUserData(SMART_ENTER_TIMESTAMP, null);
}
return true;
}
示例14: tryToMove
import com.intellij.featureStatistics.FeatureUsageTracker; //导入依赖的package包/类
public boolean tryToMove(final PsiElement element, final Project project, final DataContext dataContext, final PsiReference reference,
final Editor editor) {
if (isStaticInnerClass(element) && !JavaMoveClassesOrPackagesHandler.isReferenceInAnonymousClass(reference)) {
FeatureUsageTracker.getInstance().triggerFeatureUsed("refactoring.move.moveInner");
final PsiElement targetContainer = LangDataKeys.TARGET_PSI_ELEMENT.getData(dataContext);
PsiClass aClass = (PsiClass) element;
SelectInnerOrMembersRefactoringDialog dialog = new SelectInnerOrMembersRefactoringDialog(aClass, project);
dialog.show();
if (dialog.isOK()) {
final MoveHandlerDelegate moveHandlerDelegate = dialog.getRefactoringHandler();
if (moveHandlerDelegate != null) {
moveHandlerDelegate.doMove(project, new PsiElement[] { aClass }, targetContainer, null);
}
}
return true;
}
return false;
}
示例15: doClone
import com.intellij.featureStatistics.FeatureUsageTracker; //导入依赖的package包/类
public void doClone(PsiElement element) {
FeatureUsageTracker.getInstance().triggerFeatureUsed("refactoring.copyClass");
PsiClass[] classes = getTopLevelClasses(element);
if (classes == null) {
CopyFilesOrDirectoriesHandler.doCloneFile(element);
return;
}
Project project = element.getProject();
CopyClassDialog dialog = new CopyClassDialog(classes[0], null, project, true);
dialog.setTitle(RefactoringBundle.message("copy.handler.clone.class"));
dialog.show();
if (dialog.isOK()) {
String className = dialog.getClassName();
PsiDirectory targetDirectory = element.getContainingFile().getContainingDirectory();
copyClassesImpl(className, project, Collections.singletonMap(classes[0].getContainingFile(), classes), null, targetDirectory,
targetDirectory, RefactoringBundle.message("copy.handler.clone.class"), true, true);
}
}