• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java CorrectionEngine类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.eclipse.jdt.core.CorrectionEngine的典型用法代码示例。如果您正苦于以下问题:Java CorrectionEngine类的具体用法?Java CorrectionEngine怎么用?Java CorrectionEngine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

CorrectionEngine类属于org.eclipse.jdt.core包,在下文中一共展示了CorrectionEngine类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createFromMarker

点赞 3

import org.eclipse.jdt.core.CorrectionEngine; //导入依赖的package包/类
private static IProblemLocation createFromMarker(IMarker marker, ICompilationUnit cu) {
	try {
		int id= marker.getAttribute(IJavaModelMarker.ID, -1);
		int start= marker.getAttribute(IMarker.CHAR_START, -1);
		int end= marker.getAttribute(IMarker.CHAR_END, -1);
		int severity= marker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO);
		String[] arguments= CorrectionEngine.getProblemArguments(marker);
		String markerType= marker.getType();
		if (cu != null && id != -1 && start != -1 && end != -1 && arguments != null) {
			boolean isError= (severity == IMarker.SEVERITY_ERROR);
			return new ProblemLocation(start, end - start, id, arguments, isError, markerType);
		}
	} catch (CoreException e) {
		JavaPlugin.log(e);
	}
	return null;
}
 

开发者ID:trylimits,
项目名称:Eclipse-Postfix-Code-Completion,
代码行数:18,
代码来源:CorrectionMarkerResolutionGenerator.java

示例2: hasSuppressWarningsProposal

点赞 2

import org.eclipse.jdt.core.CorrectionEngine; //导入依赖的package包/类
public static final boolean hasSuppressWarningsProposal(IJavaProject javaProject, int problemId) {
  if (CorrectionEngine.getWarningToken(problemId) != null
      && JavaModelUtil.is50OrHigher(javaProject)) {
    String optionId = JavaCore.getOptionForConfigurableSeverity(problemId);
    if (optionId != null) {
      String optionValue = javaProject.getOption(optionId, true);
      return JavaCore.WARNING.equals(optionValue)
          || (JavaCore.ERROR.equals(optionValue)
              && JavaCore.ENABLED.equals(
                  javaProject.getOption(JavaCore.COMPILER_PB_SUPPRESS_OPTIONAL_ERRORS, true)));
    }
  }
  return false;
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:15,
代码来源:SuppressWarningsSubProcessor.java

示例3: addUnknownSuppressWarningProposals

点赞 2

import org.eclipse.jdt.core.CorrectionEngine; //导入依赖的package包/类
/**
 * Adds a proposal to correct the name of the SuppressWarning annotation
 *
 * @param context the context
 * @param problem the problem
 * @param proposals the resulting proposals
 */
public static void addUnknownSuppressWarningProposals(
    IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {

  ASTNode coveringNode = context.getCoveringNode();
  if (!(coveringNode instanceof StringLiteral)) return;

  AST ast = coveringNode.getAST();
  StringLiteral literal = (StringLiteral) coveringNode;

  String literalValue = literal.getLiteralValue();
  String[] allWarningTokens = CorrectionEngine.getAllWarningTokens();
  for (int i = 0; i < allWarningTokens.length; i++) {
    String curr = allWarningTokens[i];
    if (NameMatcher.isSimilarName(literalValue, curr)) {
      StringLiteral newLiteral = ast.newStringLiteral();
      newLiteral.setLiteralValue(curr);
      ASTRewrite rewrite = ASTRewrite.create(ast);
      rewrite.replace(literal, newLiteral, null);
      String label =
          Messages.format(
              CorrectionMessages.SuppressWarningsSubProcessor_fix_suppress_token_label,
              new String[] {curr});
      Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
      ASTRewriteCorrectionProposal proposal =
          new ASTRewriteCorrectionProposal(
              label,
              context.getCompilationUnit(),
              rewrite,
              IProposalRelevance.FIX_SUPPRESS_TOKEN,
              image);
      proposals.add(proposal);
    }
  }
  addRemoveUnusedSuppressWarningProposals(context, problem, proposals);
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:43,
代码来源:SuppressWarningsSubProcessor.java

示例4: getResolutions

点赞 2

import org.eclipse.jdt.core.CorrectionEngine; //导入依赖的package包/类
public IMarkerResolution[] getResolutions(IMarker marker) {
  if (!hasResolutions(marker)) {
    return NO_RESOLUTIONS;
  }

  ICompilationUnit cu = getCompilationUnit(marker);
  if (cu != null) {
    IEditorInput input = new FileEditorInput(
        (IFile) cu.getPrimary().getResource());
    if (input != null) {
      int offset = marker.getAttribute(IMarker.CHAR_START, -1);
      int length = marker.getAttribute(IMarker.CHAR_END, -1) - offset;
      int problemId = marker.getAttribute(IJavaModelMarker.ID, -1);
      boolean isError = (marker.getAttribute(IMarker.SEVERITY, -1) == IMarker.SEVERITY_ERROR);
      String[] arguments = CorrectionEngine.getProblemArguments(marker);

      IProblemLocation location = new ProblemLocation(offset, length,
          problemId, arguments, isError, null);
      IInvocationContext context = new AssistContext(cu, offset, length);

      IJavaCompletionProposal[] proposals = new IJavaCompletionProposal[0];

      try {
        proposals = getCorrections(context, new IProblemLocation[] {location});
      } catch (CoreException e) {
        CorePluginLog.logError(e);
      }

      int nProposals = proposals.length;
      IMarkerResolution[] resolutions = new IMarkerResolution[nProposals];
      for (int i = 0; i < nProposals; i++) {
        resolutions[i] = new QuickFixCompletionProposalWrapper(cu, offset,
            length, proposals[i]);
      }
      return resolutions;
    }
  }

  return NO_RESOLUTIONS;
}
 

开发者ID:gwt-plugins,
项目名称:gwt-eclipse-plugin,
代码行数:41,
代码来源:JavaMarkerResolutionGenerator.java

示例5: hasSuppressWarningsProposal

点赞 2

import org.eclipse.jdt.core.CorrectionEngine; //导入依赖的package包/类
public static final boolean hasSuppressWarningsProposal(IJavaProject javaProject, int problemId) {
	if (CorrectionEngine.getWarningToken(problemId) != null && JavaModelUtil.is50OrHigher(javaProject)) {
		String optionId= JavaCore.getOptionForConfigurableSeverity(problemId);
		if (optionId != null) {
			String optionValue= javaProject.getOption(optionId, true);
			return JavaCore.WARNING.equals(optionValue) ||
					(JavaCore.ERROR.equals(optionValue) && JavaCore.ENABLED.equals(javaProject.getOption(JavaCore.COMPILER_PB_SUPPRESS_OPTIONAL_ERRORS, true)));
		}
	}
	return false;
}
 

开发者ID:trylimits,
项目名称:Eclipse-Postfix-Code-Completion,
代码行数:12,
代码来源:SuppressWarningsSubProcessor.java

示例6: addUnknownSuppressWarningProposals

点赞 2

import org.eclipse.jdt.core.CorrectionEngine; //导入依赖的package包/类
/**
 * Adds a proposal to correct the name of the SuppressWarning annotation
 * @param context the context
 * @param problem the problem
 * @param proposals the resulting proposals
 */
public static void addUnknownSuppressWarningProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {

	ASTNode coveringNode= context.getCoveringNode();
	if (!(coveringNode instanceof StringLiteral))
		return;

	AST ast= coveringNode.getAST();
	StringLiteral literal= (StringLiteral) coveringNode;

	String literalValue= literal.getLiteralValue();
	String[] allWarningTokens= CorrectionEngine.getAllWarningTokens();
	for (int i= 0; i < allWarningTokens.length; i++) {
		String curr= allWarningTokens[i];
		if (NameMatcher.isSimilarName(literalValue, curr)) {
			StringLiteral newLiteral= ast.newStringLiteral();
			newLiteral.setLiteralValue(curr);
			ASTRewrite rewrite= ASTRewrite.create(ast);
			rewrite.replace(literal, newLiteral, null);
			String label= Messages.format(CorrectionMessages.SuppressWarningsSubProcessor_fix_suppress_token_label, new String[] { curr });
			Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
			ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.FIX_SUPPRESS_TOKEN, image);
			proposals.add(proposal);
		}
	}
	addRemoveUnusedSuppressWarningProposals(context, problem, proposals);
}
 

开发者ID:trylimits,
项目名称:Eclipse-Postfix-Code-Completion,
代码行数:33,
代码来源:SuppressWarningsSubProcessor.java

示例7: hasSuppressWarningsProposal

点赞 2

import org.eclipse.jdt.core.CorrectionEngine; //导入依赖的package包/类
public static final boolean hasSuppressWarningsProposal(IJavaProject javaProject, int problemId) {
	if (CorrectionEngine.getWarningToken(problemId) != null && JavaModelUtil.is50OrHigher(javaProject)) {
		String optionId= JavaCore.getOptionForConfigurableSeverity(problemId);
		if (optionId != null) {
			String optionValue= javaProject.getOption(optionId, true);
			return JavaCore.WARNING.equals(optionValue);
		}
	}
	return false;
}
 

开发者ID:trylimits,
项目名称:Eclipse-Postfix-Code-Completion-Juno38,
代码行数:11,
代码来源:SuppressWarningsSubProcessor.java

示例8: addUnknownSuppressWarningProposals

点赞 2

import org.eclipse.jdt.core.CorrectionEngine; //导入依赖的package包/类
/**
 * Adds a proposal to correct the name of the SuppressWarning annotation
 * @param context the context
 * @param problem the problem
 * @param proposals the resulting proposals
 */
public static void addUnknownSuppressWarningProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {

	ASTNode coveringNode= context.getCoveringNode();
	if (!(coveringNode instanceof StringLiteral))
		return;

	AST ast= coveringNode.getAST();
	StringLiteral literal= (StringLiteral) coveringNode;

	String literalValue= literal.getLiteralValue();
	String[] allWarningTokens= CorrectionEngine.getAllWarningTokens();
	for (int i= 0; i < allWarningTokens.length; i++) {
		String curr= allWarningTokens[i];
		if (NameMatcher.isSimilarName(literalValue, curr)) {
			StringLiteral newLiteral= ast.newStringLiteral();
			newLiteral.setLiteralValue(curr);
			ASTRewrite rewrite= ASTRewrite.create(ast);
			rewrite.replace(literal, newLiteral, null);
			String label= Messages.format(CorrectionMessages.SuppressWarningsSubProcessor_fix_suppress_token_label, new String[] { curr });
			Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
			ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 5, image);
			proposals.add(proposal);
		}
	}
	addRemoveUnusedSuppressWarningProposals(context, problem, proposals);
}
 

开发者ID:trylimits,
项目名称:Eclipse-Postfix-Code-Completion-Juno38,
代码行数:33,
代码来源:SuppressWarningsSubProcessor.java

示例9: addSuppressWarningsProposals

点赞 2

import org.eclipse.jdt.core.CorrectionEngine; //导入依赖的package包/类
public static void addSuppressWarningsProposals(
    IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
  if (problem.isError()
      && !JavaCore.ENABLED.equals(
          context
              .getCompilationUnit()
              .getJavaProject()
              .getOption(JavaCore.COMPILER_PB_SUPPRESS_OPTIONAL_ERRORS, true))) {
    return;
  }
  if (JavaCore.DISABLED.equals(
      context
          .getCompilationUnit()
          .getJavaProject()
          .getOption(JavaCore.COMPILER_PB_SUPPRESS_WARNINGS, true))) {
    return;
  }

  String warningToken = CorrectionEngine.getWarningToken(problem.getProblemId());
  if (warningToken == null) {
    return;
  }
  for (Iterator<ICommandAccess> iter = proposals.iterator(); iter.hasNext(); ) {
    Object element = iter.next();
    if (element instanceof SuppressWarningsProposal
        && warningToken.equals(((SuppressWarningsProposal) element).getWarningToken())) {
      return; // only one at a time
    }
  }

  ASTNode node = problem.getCoveringNode(context.getASTRoot());
  if (node == null) {
    return;
  }

  ASTNode target = node;
  int relevance = IProposalRelevance.ADD_SUPPRESSWARNINGS;
  do {
    relevance =
        addSuppressWarningsProposalIfPossible(
            context.getCompilationUnit(), target, warningToken, relevance, proposals);
    if (relevance == 0) return;
    target = target.getParent();
  } while (target != null);

  ASTNode importStatement = ASTNodes.getParent(node, ImportDeclaration.class);
  if (importStatement != null && !context.getASTRoot().types().isEmpty()) {
    target = (ASTNode) context.getASTRoot().types().get(0);
    if (target != null) {
      addSuppressWarningsProposalIfPossible(
          context.getCompilationUnit(),
          target,
          warningToken,
          IProposalRelevance.ADD_SUPPRESSWARNINGS,
          proposals);
    }
  }
}
 

开发者ID:eclipse,
项目名称:che,
代码行数:59,
代码来源:SuppressWarningsSubProcessor.java

示例10: getArguments

点赞 2

import org.eclipse.jdt.core.CorrectionEngine; //导入依赖的package包/类
public String[] getArguments() {
	IMarker marker= getMarker();
	if (marker != null && marker.exists() && isProblem())
		return CorrectionEngine.getProblemArguments(marker);
	return null;
}
 

开发者ID:trylimits,
项目名称:Eclipse-Postfix-Code-Completion,
代码行数:7,
代码来源:JavaMarkerAnnotation.java

示例11: addSuppressWarningsProposals

点赞 2

import org.eclipse.jdt.core.CorrectionEngine; //导入依赖的package包/类
public static void addSuppressWarningsProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
	if (problem.isError() && ! JavaCore.ENABLED.equals(context.getCompilationUnit().getJavaProject().getOption(JavaCore.COMPILER_PB_SUPPRESS_OPTIONAL_ERRORS, true))) {
		return;
	}
	if (JavaCore.DISABLED.equals(context.getCompilationUnit().getJavaProject().getOption(JavaCore.COMPILER_PB_SUPPRESS_WARNINGS, true))) {
		return;
	}

	String warningToken= CorrectionEngine.getWarningToken(problem.getProblemId());
	if (warningToken == null) {
		return;
	}
	for (Iterator<ICommandAccess> iter= proposals.iterator(); iter.hasNext();) {
		Object element= iter.next();
		if (element instanceof SuppressWarningsProposal && warningToken.equals(((SuppressWarningsProposal) element).getWarningToken())) {
			return; // only one at a time
		}
	}

	ASTNode node= problem.getCoveringNode(context.getASTRoot());
	if (node == null) {
		return;
	}
	
	ASTNode target= node;
	int relevance= IProposalRelevance.ADD_SUPPRESSWARNINGS;
	do {
		relevance= addSuppressWarningsProposalIfPossible(context.getCompilationUnit(), target, warningToken, relevance, proposals);
		if (relevance == 0)
			return;
		target= target.getParent();
	} while (target != null);
	
	ASTNode importStatement= ASTNodes.getParent(node, ImportDeclaration.class);
	if (importStatement != null && !context.getASTRoot().types().isEmpty()) {
		target= (ASTNode) context.getASTRoot().types().get(0);
		if (target != null) {
			addSuppressWarningsProposalIfPossible(context.getCompilationUnit(), target, warningToken, IProposalRelevance.ADD_SUPPRESSWARNINGS, proposals);
		}
	}
}
 

开发者ID:trylimits,
项目名称:Eclipse-Postfix-Code-Completion,
代码行数:42,
代码来源:SuppressWarningsSubProcessor.java

示例12: addSuppressWarningsProposals

点赞 2

import org.eclipse.jdt.core.CorrectionEngine; //导入依赖的package包/类
public static void addSuppressWarningsProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
	if (problem.isError() && ! JavaCore.ENABLED.equals(context.getCompilationUnit().getJavaProject().getOption(JavaCore.COMPILER_PB_SUPPRESS_OPTIONAL_ERRORS, true))) {
		return;
	}
	if (JavaCore.DISABLED.equals(context.getCompilationUnit().getJavaProject().getOption(JavaCore.COMPILER_PB_SUPPRESS_WARNINGS, true))) {
		return;
	}

	String warningToken= CorrectionEngine.getWarningToken(problem.getProblemId());
	if (warningToken == null) {
		return;
	}
	for (Iterator<ICommandAccess> iter= proposals.iterator(); iter.hasNext();) {
		Object element= iter.next();
		if (element instanceof SuppressWarningsProposal && warningToken.equals(((SuppressWarningsProposal) element).getWarningToken())) {
			return; // only one at a time
		}
	}

	ASTNode node= problem.getCoveringNode(context.getASTRoot());
	if (node == null) {
		return;
	}
	
	ASTNode target= node;
	int relevance= -2;
	do {
		relevance= addSuppressWarningsProposalIfPossible(context.getCompilationUnit(), target, warningToken, relevance, proposals);
		if (relevance == 0)
			return;
		target= target.getParent();
	} while (target != null);
	
	ASTNode importStatement= ASTNodes.getParent(node, ImportDeclaration.class);
	if (importStatement != null && !context.getASTRoot().types().isEmpty()) {
		target= (ASTNode) context.getASTRoot().types().get(0);
		if (target != null) {
			addSuppressWarningsProposalIfPossible(context.getCompilationUnit(), target, warningToken, -2, proposals);
		}
	}
}
 

开发者ID:trylimits,
项目名称:Eclipse-Postfix-Code-Completion-Juno38,
代码行数:42,
代码来源:SuppressWarningsSubProcessor.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)