本文整理汇总了Java中org.eclipse.jdt.ui.text.java.IInvocationContext类的典型用法代码示例。如果您正苦于以下问题:Java IInvocationContext类的具体用法?Java IInvocationContext怎么用?Java IInvocationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IInvocationContext类属于org.eclipse.jdt.ui.text.java包,在下文中一共展示了IInvocationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCorrections
import org.eclipse.jdt.ui.text.java.IInvocationContext; //导入依赖的package包/类
@Override
public IJavaCompletionProposal[] getCorrections(IInvocationContext context,
IProblemLocation[] locations) throws CoreException {
for (final IProblemLocation problem : locations) {
if ((problem.getProblemId() == IProblem.UnresolvedVariable
|| problem.getProblemId() == IProblem.UndefinedType)
&& Utils.isAPGAS(problem.getProblemArguments()[0])) {
if (!apgasInBuildPath(context.getCompilationUnit().getJavaProject())) {
return getAddAPGASToBuildPathProposals(context);
}
} else if (problem.getProblemId() == IProblem.UndefinedMethod
&& Utils.isAPGAS(problem.getProblemArguments()[1])) {
if (!apgasInBuildPath(context.getCompilationUnit().getJavaProject())) {
return getAddAPGASToBuildPathProposals(context);
} else {
return getImportStaticConstructsProposal(context);
}
}
}
return null;
}
示例2: getImportStaticConstructsProposal
import org.eclipse.jdt.ui.text.java.IInvocationContext; //导入依赖的package包/类
private IJavaCompletionProposal[] getImportStaticConstructsProposal(
IInvocationContext context) {
final ICompilationUnit unit = context.getCompilationUnit();
final IJavaProject project = unit.getJavaProject();
final ImportRewrite rewrite = getImportRewrite(context.getASTRoot(),
"static apgas.Constructs.*");
final ArrayList<IJavaCompletionProposal> proposals = new ArrayList<IJavaCompletionProposal>();
proposals.add(new ConstructsImportProposal(project, rewrite));
final IJavaCompletionProposal[] propArr = new IJavaCompletionProposal[proposals
.size()];
for (int i = 0; i < proposals.size(); i++) {
propArr[i] = proposals.get(i);
}
return propArr;
}
示例3: getAddAPGASToBuildPathProposals
import org.eclipse.jdt.ui.text.java.IInvocationContext; //导入依赖的package包/类
private IJavaCompletionProposal[] getAddAPGASToBuildPathProposals(
IInvocationContext context) {
final ICompilationUnit unit = context.getCompilationUnit();
final IJavaProject project = unit.getJavaProject();
final String name = "static apgas.Constructs.*";
final ClasspathFixProposal[] fixProposals = ClasspathFixProcessor
.getContributedFixImportProposals(project, name, null);
final List<ImportRewrite> importRewrites = new ArrayList<ImportRewrite>();
importRewrites.add(getImportRewrite(context.getASTRoot(), name));
importRewrites.add(getImportRewrite(context.getASTRoot(), "apgas.*"));
final ArrayList<IJavaCompletionProposal> proposals = new ArrayList<IJavaCompletionProposal>();
for (final ClasspathFixProposal fixProposal : fixProposals) {
proposals.add(new APGASClasspathFixCorrelationProposal(project,
fixProposal, importRewrites));
}
final IJavaCompletionProposal[] propArr = new IJavaCompletionProposal[proposals
.size()];
for (int i = 0; i < proposals.size(); i++) {
propArr[i] = proposals.get(i);
}
return propArr;
}
示例4: collectAssists
import org.eclipse.jdt.ui.text.java.IInvocationContext; //导入依赖的package包/类
protected static final ArrayList collectAssists(IInvocationContext context, Class[] filteredTypes)
throws CoreException {
ArrayList proposals = new ArrayList();
IStatus status =
JavaCorrectionProcessor.collectAssists(context, new IProblemLocation[0], proposals);
assertStatusOk(status);
if (!proposals.isEmpty()) {
assertTrue("should be marked as 'has assist'", JavaCorrectionProcessor.hasAssists(context));
}
if (filteredTypes != null && filteredTypes.length > 0) {
for (Iterator iter = proposals.iterator(); iter.hasNext(); ) {
if (isFiltered(iter.next(), filteredTypes)) {
iter.remove();
}
}
}
return proposals;
}
示例5: getUnnecessaryNLSTagProposals
import org.eclipse.jdt.ui.text.java.IInvocationContext; //导入依赖的package包/类
public static void getUnnecessaryNLSTagProposals(
IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals)
throws CoreException {
IProposableFix fix = StringFix.createFix(context.getASTRoot(), problem, true, false);
if (fix != null) {
Image image =
JavaPluginImages.get(
JavaPluginImages
.IMG_TOOL_DELETE); // JavaPlugin.getDefault().getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE);
Map<String, String> options = new Hashtable<String, String>();
options.put(CleanUpConstants.REMOVE_UNNECESSARY_NLS_TAGS, CleanUpOptions.TRUE);
FixCorrectionProposal proposal =
new FixCorrectionProposal(
fix,
new StringCleanUp(options),
IProposalRelevance.UNNECESSARY_NLS_TAG,
image,
context);
proposal.setCommandId(REMOVE_UNNECESSARY_NLS_TAG_ID);
proposals.add(proposal);
}
}
示例6: addUnusedMemberProposal
import org.eclipse.jdt.ui.text.java.IInvocationContext; //导入依赖的package包/类
public static void addUnusedMemberProposal(
IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
int problemId = problem.getProblemId();
UnusedCodeFix fix = UnusedCodeFix.createUnusedMemberFix(context.getASTRoot(), problem, false);
if (fix != null) {
addProposal(context, proposals, fix);
}
if (problemId == IProblem.LocalVariableIsNeverUsed) {
fix = UnusedCodeFix.createUnusedMemberFix(context.getASTRoot(), problem, true);
addProposal(context, proposals, fix);
}
if (problemId == IProblem.ArgumentIsNeverUsed) {
JavadocTagsSubProcessor.getUnusedAndUndocumentedParameterOrExceptionProposals(
context, problem, proposals);
}
if (problemId == IProblem.UnusedPrivateField) {
GetterSetterCorrectionSubProcessor.addGetterSetterProposal(
context, problem, proposals, IProposalRelevance.GETTER_SETTER_UNUSED_PRIVATE_FIELD);
}
}
示例7: addRedundantSuperInterfaceProposal
import org.eclipse.jdt.ui.text.java.IInvocationContext; //导入依赖的package包/类
public static void addRedundantSuperInterfaceProposal(
IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
ASTNode selectedNode = problem.getCoveringNode(context.getASTRoot());
if (!(selectedNode instanceof Name)) {
return;
}
ASTNode node = ASTNodes.getNormalizedNode(selectedNode);
ASTRewrite rewrite = ASTRewrite.create(node.getAST());
rewrite.remove(node, null);
String label = CorrectionMessages.LocalCorrectionsSubProcessor_remove_redundant_superinterface;
Image image =
JavaPluginImages.get(
JavaPluginImages
.IMG_TOOL_DELETE); // JavaPlugin.getDefault().getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE);
ASTRewriteCorrectionProposal proposal =
new ASTRewriteCorrectionProposal(
label,
context.getCompilationUnit(),
rewrite,
IProposalRelevance.REMOVE_REDUNDANT_SUPER_INTERFACE,
image);
proposals.add(proposal);
}
示例8: addUnnecessaryCastProposal
import org.eclipse.jdt.ui.text.java.IInvocationContext; //导入依赖的package包/类
public static void addUnnecessaryCastProposal(
IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
IProposableFix fix = UnusedCodeFix.createRemoveUnusedCastFix(context.getASTRoot(), problem);
if (fix != null) {
Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
Map<String, String> options = new Hashtable<String, String>();
options.put(CleanUpConstants.REMOVE_UNNECESSARY_CASTS, CleanUpOptions.TRUE);
FixCorrectionProposal proposal =
new FixCorrectionProposal(
fix,
new UnnecessaryCodeCleanUp(options),
IProposalRelevance.REMOVE_UNUSED_CAST,
image,
context);
proposals.add(proposal);
}
}
示例9: getRemoveJavadocTagProposals
import org.eclipse.jdt.ui.text.java.IInvocationContext; //导入依赖的package包/类
public static void getRemoveJavadocTagProposals(
IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
ASTNode node = problem.getCoveringNode(context.getASTRoot());
while (node != null && !(node instanceof TagElement)) {
node = node.getParent();
}
if (node == null) {
return;
}
ASTRewrite rewrite = ASTRewrite.create(node.getAST());
rewrite.remove(node, null);
String label = CorrectionMessages.JavadocTagsSubProcessor_removetag_description;
Image image =
JavaPluginImages.get(
JavaPluginImages
.IMG_TOOL_DELETE); // JavaPlugin.getDefault().getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE);
proposals.add(
new ASTRewriteCorrectionProposal(
label, context.getCompilationUnit(), rewrite, IProposalRelevance.REMOVE_TAG, image));
}
示例10: addUnqualifiedFieldAccessProposal
import org.eclipse.jdt.ui.text.java.IInvocationContext; //导入依赖的package包/类
public static void addUnqualifiedFieldAccessProposal(
IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
IProposableFix fix = CodeStyleFix.createAddFieldQualifierFix(context.getASTRoot(), problem);
if (fix != null) {
Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
Map<String, String> options = new HashMap<String, String>();
options.put(CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS, CleanUpOptions.TRUE);
options.put(
CleanUpConstants.MEMBER_ACCESSES_NON_STATIC_FIELD_USE_THIS_ALWAYS, CleanUpOptions.TRUE);
FixCorrectionProposal proposal =
new FixCorrectionProposal(
fix,
new CodeStyleCleanUp(options),
IProposalRelevance.ADD_FIELD_QUALIFIER,
image,
context);
proposal.setCommandId(ADD_FIELD_QUALIFICATION_ID);
proposals.add(proposal);
}
}
示例11: addRemoveRedundantTypeArgumentsProposals
import org.eclipse.jdt.ui.text.java.IInvocationContext; //导入依赖的package包/类
public static void addRemoveRedundantTypeArgumentsProposals(
IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
IProposableFix fix =
TypeParametersFix.createRemoveRedundantTypeArgumentsFix(context.getASTRoot(), problem);
if (fix != null) {
Image image =
JavaPluginImages.get(
JavaPluginImages
.IMG_TOOL_DELETE); // JavaPlugin.getDefault().getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE);
Map<String, String> options = new HashMap<String, String>();
options.put(CleanUpConstants.USE_TYPE_ARGUMENTS, CleanUpOptions.TRUE);
options.put(CleanUpConstants.REMOVE_REDUNDANT_TYPE_ARGUMENTS, CleanUpOptions.TRUE);
FixCorrectionProposal proposal =
new FixCorrectionProposal(
fix,
new TypeParametersCleanUp(options),
IProposalRelevance.REMOVE_REDUNDANT_TYPE_ARGUMENTS,
image,
context);
proposals.add(proposal);
}
}
示例12: addRemoveRedundantAnnotationProposal
import org.eclipse.jdt.ui.text.java.IInvocationContext; //导入依赖的package包/类
public static void addRemoveRedundantAnnotationProposal(
IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
NullAnnotationsFix fix =
NullAnnotationsFix.createRemoveRedundantNullAnnotationsFix(context.getASTRoot(), problem);
if (fix == null) return;
Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
Map<String, String> options = new Hashtable<String, String>();
FixCorrectionProposal proposal =
new FixCorrectionProposal(
fix,
new NullAnnotationsCleanUp(options, problem.getProblemId()),
IProposalRelevance.REMOVE_REDUNDANT_NULLNESS_ANNOTATION,
image,
context);
proposals.add(proposal);
}
示例13: addExtractCheckedLocalProposal
import org.eclipse.jdt.ui.text.java.IInvocationContext; //导入依赖的package包/类
/**
* Fix for {@link IProblem#NullableFieldReference}
*
* @param context context
* @param problem problem to be fixed
* @param proposals accumulator for computed proposals
*/
public static void addExtractCheckedLocalProposal(
IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
CompilationUnit compilationUnit = context.getASTRoot();
ICompilationUnit cu = (ICompilationUnit) compilationUnit.getJavaElement();
ASTNode selectedNode = problem.getCoveringNode(compilationUnit);
SimpleName name = findProblemFieldName(selectedNode, problem.getProblemId());
if (name == null) return;
ASTNode method = ASTNodes.getParent(selectedNode, MethodDeclaration.class);
if (method == null) method = ASTNodes.getParent(selectedNode, Initializer.class);
if (method == null) return;
proposals.add(new ExtractToNullCheckedLocalProposal(cu, compilationUnit, name, method));
}
示例14: CorrectMainTypeNameProposal
import org.eclipse.jdt.ui.text.java.IInvocationContext; //导入依赖的package包/类
/**
* Constructor for CorrectTypeNameProposal.
*
* @param cu the compilation unit
* @param context the invocation context
* @param oldTypeName the old type name
* @param newTypeName the new type name
* @param relevance the relevance
*/
public CorrectMainTypeNameProposal(
ICompilationUnit cu,
IInvocationContext context,
String oldTypeName,
String newTypeName,
int relevance) {
super("", cu, null, relevance, null); // $NON-NLS-1$
fContext = context;
setDisplayName(
Messages.format(
CorrectionMessages.ReorgCorrectionsSubProcessor_renametype_description,
BasicElementLabels.getJavaElementName(newTypeName)));
setImage(JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE));
fOldName = oldTypeName;
fNewName = newTypeName;
}
示例15: getNeedHigherComplianceProposals
import org.eclipse.jdt.ui.text.java.IInvocationContext; //导入依赖的package包/类
/**
* Adds a proposal to increase the compiler compliance level
*
* @param context the context
* @param problem the current problem
* @param proposals the resulting proposals
* @param requiredVersion the minimal required Java compiler version
*/
public static void getNeedHigherComplianceProposals(
IInvocationContext context,
IProblemLocation problem,
Collection<ICommandAccess> proposals,
String requiredVersion) {
// IJavaProject project = context.getCompilationUnit().getJavaProject();
//
// String label1 =
//
// Messages.format(CorrectionMessages.ReorgCorrectionsSubProcessor_change_project_compliance_description, requiredVersion);
// proposals.add(new ChangeToRequiredCompilerCompliance(label1, project, false,
// requiredVersion,
// IProposalRelevance.CHANGE_PROJECT_COMPLIANCE));
//
// if (project.getOption(JavaCore.COMPILER_COMPLIANCE, false) == null) {
// String label2 =
// Messages.format(CorrectionMessages.ReorgCorrectionsSubProcessor_change_workspace_compliance_description,
// requiredVersion);
// proposals.add(new ChangeToRequiredCompilerCompliance(label2, project, true,
// requiredVersion,
// IProposalRelevance.CHANGE_WORKSPACE_COMPLIANCE));
// }
}