本文整理汇总了Java中org.eclipse.jdt.ui.text.java.IProblemLocation类的典型用法代码示例。如果您正苦于以下问题:Java IProblemLocation类的具体用法?Java IProblemLocation怎么用?Java IProblemLocation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IProblemLocation类属于org.eclipse.jdt.ui.text.java包,在下文中一共展示了IProblemLocation类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getCorrections
import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入依赖的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;
}
开发者ID:x10-lang,项目名称:apgas,代码行数:22,代码来源:APGASQuickfixProcessor.java
示例2: createCleanUp
import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入依赖的package包/类
public static ICleanUpFix createCleanUp(
CompilationUnit compilationUnit, IProblemLocation[] locations, int problemID) {
ICompilationUnit cu = (ICompilationUnit) compilationUnit.getJavaElement();
if (!JavaModelUtil.is50OrHigher(cu.getJavaProject())) return null;
List<CompilationUnitRewriteOperation> operations =
new ArrayList<CompilationUnitRewriteOperation>();
if (locations == null) {
org.eclipse.jdt.core.compiler.IProblem[] problems = compilationUnit.getProblems();
locations = new IProblemLocation[problems.length];
for (int i = 0; i < problems.length; i++) {
if (problems[i].getID() == problemID) locations[i] = new ProblemLocation(problems[i]);
}
}
createAddNullAnnotationOperations(compilationUnit, locations, operations);
createRemoveRedundantNullAnnotationsOperations(compilationUnit, locations, operations);
if (operations.size() == 0) return null;
CompilationUnitRewriteOperation[] operationsArray =
operations.toArray(new CompilationUnitRewriteOperation[operations.size()]);
return new NullAnnotationsFix(
FixMessages.NullAnnotationsFix_add_annotation_change_name,
compilationUnit,
operationsArray);
}
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:NullAnnotationsFix.java
示例3: createRemoveRedundantNullAnnotationsOperations
import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入依赖的package包/类
private static void createRemoveRedundantNullAnnotationsOperations(
CompilationUnit compilationUnit,
IProblemLocation[] locations,
List<CompilationUnitRewriteOperation> result) {
for (int i = 0; i < locations.length; i++) {
IProblemLocation problem = locations[i];
if (problem == null) continue; // problem was filtered out by createCleanUp()
int problemId = problem.getProblemId();
if (problemId == IProblem.RedundantNullAnnotation
|| problemId == IProblem.RedundantNullDefaultAnnotationPackage
|| problemId == IProblem.RedundantNullDefaultAnnotationType
|| problemId == IProblem.RedundantNullDefaultAnnotationMethod) {
RemoveRedundantAnnotationRewriteOperation operation =
new RemoveRedundantAnnotationRewriteOperation(compilationUnit, problem);
result.add(operation);
}
}
}
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:NullAnnotationsFix.java
示例4: createFix
import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected ICleanUpFix createFix(CompilationUnit unit) throws CoreException {
IProblemLocation[] problemLocations = convertProblems(unit.getProblems());
problemLocations =
filter(
problemLocations,
new int[] {
IProblem.AbstractMethodMustBeImplemented,
IProblem.EnumConstantMustImplementAbstractMethod
});
return UnimplementedCodeFix.createCleanUp(
unit,
isEnabled(CleanUpConstants.ADD_MISSING_METHODES),
isEnabled(MAKE_TYPE_ABSTRACT),
problemLocations);
}
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:UnimplementedCodeCleanUp.java
示例5: createIndirectAccessToStaticFix
import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入依赖的package包/类
public static CompilationUnitRewriteOperationsFix createIndirectAccessToStaticFix(
CompilationUnit compilationUnit, IProblemLocation problem) {
if (!isIndirectStaticAccess(problem)) return null;
ToStaticAccessOperation operations[] =
createToStaticAccessOperations(
compilationUnit, new HashMap<ASTNode, Block>(), problem, false);
if (operations == null) return null;
String label =
Messages.format(
FixMessages.CodeStyleFix_ChangeStaticAccess_description,
operations[0].getAccessorName());
return new CodeStyleFix(
label, compilationUnit, new CompilationUnitRewriteOperation[] {operations[0]});
}
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:CodeStyleFix.java
示例6: getSelectedTypeNode
import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入依赖的package包/类
public static ASTNode getSelectedTypeNode(CompilationUnit root, IProblemLocation problem) {
ASTNode selectedNode = problem.getCoveringNode(root);
if (selectedNode == null) return null;
if (selectedNode.getNodeType() == ASTNode.ANONYMOUS_CLASS_DECLARATION) { // bug 200016
selectedNode = selectedNode.getParent();
}
if (selectedNode.getLocationInParent() == EnumConstantDeclaration.NAME_PROPERTY) {
selectedNode = selectedNode.getParent();
}
if (selectedNode.getNodeType() == ASTNode.SIMPLE_NAME
&& selectedNode.getParent() instanceof AbstractTypeDeclaration) {
return selectedNode.getParent();
} else if (selectedNode.getNodeType() == ASTNode.CLASS_INSTANCE_CREATION) {
return ((ClassInstanceCreation) selectedNode).getAnonymousClassDeclaration();
} else if (selectedNode.getNodeType() == ASTNode.ENUM_CONSTANT_DECLARATION) {
EnumConstantDeclaration enumConst = (EnumConstantDeclaration) selectedNode;
if (enumConst.getAnonymousClassDeclaration() != null)
return enumConst.getAnonymousClassDeclaration();
return enumConst;
} else {
return null;
}
}
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:UnimplementedCodeFix.java
示例7: createFix
import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入依赖的package包/类
private static Java50Fix createFix(
CompilationUnit compilationUnit, IProblemLocation problem, String annotation, String label) {
ICompilationUnit cu = (ICompilationUnit) compilationUnit.getJavaElement();
if (!JavaModelUtil.is50OrHigher(cu.getJavaProject())) return null;
ASTNode selectedNode = problem.getCoveringNode(compilationUnit);
if (selectedNode == null) return null;
ASTNode declaringNode = getDeclaringNode(selectedNode);
if (!(declaringNode instanceof BodyDeclaration)) return null;
BodyDeclaration declaration = (BodyDeclaration) declaringNode;
AnnotationRewriteOperation operation = new AnnotationRewriteOperation(declaration, annotation);
return new Java50Fix(label, compilationUnit, new CompilationUnitRewriteOperation[] {operation});
}
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:Java50Fix.java
示例8: createRawTypeReferenceFix
import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入依赖的package包/类
public static Java50Fix createRawTypeReferenceFix(
CompilationUnit compilationUnit, IProblemLocation problem) {
List<CompilationUnitRewriteOperation> operations =
new ArrayList<CompilationUnitRewriteOperation>();
SimpleType node =
createRawTypeReferenceOperations(
compilationUnit, new IProblemLocation[] {problem}, operations);
if (operations.size() == 0) return null;
return new Java50Fix(
Messages.format(
FixMessages.Java50Fix_AddTypeArguments_description,
BasicElementLabels.getJavaElementName(node.getName().getFullyQualifiedName())),
compilationUnit,
operations.toArray(new CompilationUnitRewriteOperation[operations.size()]));
}
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:Java50Fix.java
示例9: getRemoveJavadocTagProposals
import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入依赖的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));
}
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:JavadocTagsSubProcessor.java
示例10: createAddDeprecatedAnnotationOperations
import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入依赖的package包/类
private static void createAddDeprecatedAnnotationOperations(
CompilationUnit compilationUnit,
IProblemLocation[] locations,
List<CompilationUnitRewriteOperation> result) {
for (int i = 0; i < locations.length; i++) {
IProblemLocation problem = locations[i];
if (isMissingDeprecationProblem(problem.getProblemId())) {
ASTNode selectedNode = problem.getCoveringNode(compilationUnit);
if (selectedNode != null) {
ASTNode declaringNode = getDeclaringNode(selectedNode);
if (declaringNode instanceof BodyDeclaration) {
BodyDeclaration declaration = (BodyDeclaration) declaringNode;
AnnotationRewriteOperation operation =
new AnnotationRewriteOperation(declaration, DEPRECATED);
result.add(operation);
}
}
}
}
}
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:Java50Fix.java
示例11: createRemoveUnusedCastFix
import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入依赖的package包/类
public static UnusedCodeFix createRemoveUnusedCastFix(
CompilationUnit compilationUnit, IProblemLocation problem) {
if (problem.getProblemId() != IProblem.UnnecessaryCast) return null;
ASTNode selectedNode = problem.getCoveringNode(compilationUnit);
ASTNode curr = selectedNode;
while (curr instanceof ParenthesizedExpression) {
curr = ((ParenthesizedExpression) curr).getExpression();
}
if (!(curr instanceof CastExpression)) return null;
return new UnusedCodeFix(
FixMessages.UnusedCodeFix_RemoveCast_description,
compilationUnit,
new CompilationUnitRewriteOperation[] {new RemoveCastOperation((CastExpression) curr)});
}
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:UnusedCodeFix.java
示例12: addUnusedMemberProposal
import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入依赖的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);
}
}
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:LocalCorrectionsSubProcessor.java
示例13: addRedundantSuperInterfaceProposal
import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入依赖的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);
}
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:LocalCorrectionsSubProcessor.java
示例14: addUnnecessaryCastProposal
import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入依赖的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);
}
}
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:LocalCorrectionsSubProcessor.java
示例15: addMethodWithConstrNameProposals
import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入依赖的package包/类
public static void addMethodWithConstrNameProposals(
IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
ICompilationUnit cu = context.getCompilationUnit();
ASTNode selectedNode = problem.getCoveringNode(context.getASTRoot());
if (selectedNode instanceof MethodDeclaration) {
MethodDeclaration declaration = (MethodDeclaration) selectedNode;
ASTRewrite rewrite = ASTRewrite.create(declaration.getAST());
rewrite.set(declaration, MethodDeclaration.CONSTRUCTOR_PROPERTY, Boolean.TRUE, null);
String label = CorrectionMessages.ReturnTypeSubProcessor_constrnamemethod_description;
Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
ASTRewriteCorrectionProposal proposal =
new ASTRewriteCorrectionProposal(
label, cu, rewrite, IProposalRelevance.CHANGE_TO_CONSTRUCTOR, image);
proposals.add(proposal);
}
}
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:ReturnTypeSubProcessor.java
示例16: computeNumberOfFixes
import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public int computeNumberOfFixes(CompilationUnit compilationUnit) {
if (!isEnabled(CleanUpConstants.ADD_MISSING_METHODES) && !isEnabled(MAKE_TYPE_ABSTRACT))
return 0;
IProblemLocation[] locations =
filter(
convertProblems(compilationUnit.getProblems()),
new int[] {
IProblem.AbstractMethodMustBeImplemented,
IProblem.EnumConstantMustImplementAbstractMethod
});
HashSet<ASTNode> types = new HashSet<ASTNode>();
for (int i = 0; i < locations.length; i++) {
ASTNode type = UnimplementedCodeFix.getSelectedTypeNode(compilationUnit, locations[i]);
if (type != null) {
types.add(type);
}
}
return types.size();
}
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:UnimplementedCodeCleanUp.java
示例17: getSerialVersionProposals
import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入依赖的package包/类
/**
* Determines the serial version quickfix proposals.
*
* @param context the invocation context
* @param location the problem location
* @param proposals the proposal collection to extend
*/
public static final void getSerialVersionProposals(
final IInvocationContext context,
final IProblemLocation location,
final Collection<ICommandAccess> proposals) {
Assert.isNotNull(context);
Assert.isNotNull(location);
Assert.isNotNull(proposals);
IProposableFix[] fixes =
PotentialProgrammingProblemsFix.createMissingSerialVersionFixes(
context.getASTRoot(), location);
if (fixes != null) {
proposals.add(
new SerialVersionProposal(
fixes[0], IProposalRelevance.MISSING_SERIAL_VERSION_DEFAULT, context, true));
proposals.add(
new SerialVersionProposal(
fixes[1], IProposalRelevance.MISSING_SERIAL_VERSION, context, false));
}
}
开发者ID:eclipse,项目名称:che,代码行数:29,代码来源:SerialVersionSubProcessor.java
示例18: canFix
import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入依赖的package包/类
/** {@inheritDoc} */
public boolean canFix(ICompilationUnit compilationUnit, IProblemLocation problem) {
if (UnusedCodeFix.isUnusedImport(problem))
return isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_IMPORTS);
if (UnusedCodeFix.isUnusedMember(problem))
return isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS)
&& isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_METHODS)
|| isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS)
&& isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_CONSTRUCTORS)
|| isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS)
&& isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_TYPES)
|| isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_MEMBERS)
&& isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_PRIVATE_FELDS)
|| isEnabled(CleanUpConstants.REMOVE_UNUSED_CODE_LOCAL_VARIABLES);
return false;
}
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:UnusedCodeCleanUp.java
示例19: noErrorsAtLocation
import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入依赖的package包/类
static boolean noErrorsAtLocation(IProblemLocation[] locations) {
if (locations != null) {
for (int i = 0; i < locations.length; i++) {
IProblemLocation location = locations[i];
if (location.isError()) {
if (IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER.equals(location.getMarkerType())
&& JavaCore.getOptionForConfigurableSeverity(location.getProblemId()) != null) {
// continue (only drop out for severe (non-optional) errors)
} else {
return false;
}
}
}
}
return true;
}
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:QuickAssistProcessor.java
示例20: addRemoveRedundantAnnotationProposal
import org.eclipse.jdt.ui.text.java.IProblemLocation; //导入依赖的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);
}
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:NullAnnotationsCorrectionProcessor.java
注:本文中的org.eclipse.jdt.ui.text.java.IProblemLocation类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论