本文整理汇总了Java中org.eclipse.ltk.core.refactoring.RefactoringStatus.addEntry方法的典型用法代码示例。如果您正苦于以下问题:Java RefactoringStatus.addEntry方法的具体用法?Java RefactoringStatus.addEntry怎么用?Java RefactoringStatus.addEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ltk.core.refactoring.RefactoringStatus
的用法示例。
在下文中一共展示了RefactoringStatus.addEntry方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addEntry
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private static void addEntry(RefactoringStatus status, IMethod sourceMethod, int severity,
PreconditionFailure failure, IJavaElement... relatedElementCollection) {
String message = formatMessage(failure.getMessage(), relatedElementCollection);
// add the first element as the context if appropriate.
if (relatedElementCollection.length > 0 && relatedElementCollection[0] instanceof IMember) {
IMember member = (IMember) relatedElementCollection[0];
RefactoringStatusContext context = JavaStatusContext.create(member);
status.addEntry(new RefactoringStatusEntry(severity, message, context,
MigrateSkeletalImplementationToInterfaceRefactoringDescriptor.REFACTORING_ID, failure.ordinal(),
sourceMethod));
} else // otherwise, just add the message.
status.addEntry(new RefactoringStatusEntry(severity, message, null,
MigrateSkeletalImplementationToInterfaceRefactoringDescriptor.REFACTORING_ID, failure.ordinal(),
sourceMethod));
}
开发者ID:ponder-lab,项目名称:Migrate-Skeletal-Implementation-to-Interface-Refactoring,代码行数:17,代码来源:MigrateSkeletalImplementationToInterfaceRefactoringProcessor.java
示例2: checkAccessedTypes
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private RefactoringStatus checkAccessedTypes(IMethod sourceMethod, final Optional<IProgressMonitor> monitor,
final ITypeHierarchy hierarchy) throws JavaModelException {
final RefactoringStatus result = new RefactoringStatus();
final IType[] accessedTypes = getTypesReferencedInMovedMembers(sourceMethod, monitor);
final IType destination = getDestinationInterface(sourceMethod).get();
final List<IMember> pulledUpList = Arrays.asList(sourceMethod);
for (IType type : accessedTypes) {
if (!type.exists())
continue;
if (!canBeAccessedFrom(sourceMethod, type, destination, hierarchy) && !pulledUpList.contains(type)) {
final String message = org.eclipse.jdt.internal.corext.util.Messages.format(
PreconditionFailure.TypeNotAccessible.getMessage(),
new String[] { JavaElementLabels.getTextLabel(type, JavaElementLabels.ALL_FULLY_QUALIFIED),
JavaElementLabels.getTextLabel(destination, JavaElementLabels.ALL_FULLY_QUALIFIED) });
result.addEntry(RefactoringStatus.ERROR, message, JavaStatusContext.create(type),
MigrateSkeletalImplementationToInterfaceRefactoringDescriptor.REFACTORING_ID,
PreconditionFailure.TypeNotAccessible.ordinal(), sourceMethod);
this.getUnmigratableMethods().add(sourceMethod);
}
}
monitor.ifPresent(IProgressMonitor::done);
return result;
}
开发者ID:ponder-lab,项目名称:Migrate-Skeletal-Implementation-to-Interface-Refactoring,代码行数:25,代码来源:MigrateSkeletalImplementationToInterfaceRefactoringProcessor.java
示例3: checkCompilationofDeclaringCu
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private RefactoringStatus checkCompilationofDeclaringCu() throws CoreException {
ICompilationUnit cu = getCu();
TextChange change = fChangeManager.get(cu);
String newCuSource = change.getPreviewContent(new NullProgressMonitor());
CompilationUnit newCUNode =
new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL)
.parse(newCuSource, cu, true, false, null);
IProblem[] problems =
RefactoringAnalyzeUtil.getIntroducedCompileProblems(newCUNode, fBaseCuRewrite.getRoot());
RefactoringStatus result = new RefactoringStatus();
for (int i = 0; i < problems.length; i++) {
IProblem problem = problems[i];
if (shouldReport(problem, newCUNode))
result.addEntry(
new RefactoringStatusEntry(
(problem.isError() ? RefactoringStatus.ERROR : RefactoringStatus.WARNING),
problem.getMessage(),
new JavaStringStatusContext(newCuSource, SourceRangeFactory.create(problem))));
}
return result;
}
示例4: analyzeCompileErrors
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private static RefactoringStatus analyzeCompileErrors(
String newCuSource, CompilationUnit newCUNode, CompilationUnit oldCUNode) {
RefactoringStatus result = new RefactoringStatus();
IProblem[] newProblems =
RefactoringAnalyzeUtil.getIntroducedCompileProblems(newCUNode, oldCUNode);
for (int i = 0; i < newProblems.length; i++) {
IProblem problem = newProblems[i];
if (problem.isError())
result.addEntry(
new RefactoringStatusEntry(
(problem.isError() ? RefactoringStatus.ERROR : RefactoringStatus.WARNING),
problem.getMessage(),
new JavaStringStatusContext(newCuSource, SourceRangeFactory.create(problem))));
}
return result;
}
示例5: checkNewSource
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private void checkNewSource(SubProgressMonitor monitor, RefactoringStatus result)
throws CoreException {
String newCuSource = fChange.getPreviewContent(new NullProgressMonitor());
CompilationUnit newCUNode =
new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL)
.parse(newCuSource, fCu, true, true, monitor);
IProblem[] newProblems =
RefactoringAnalyzeUtil.getIntroducedCompileProblems(newCUNode, fCompilationUnitNode);
for (int i = 0; i < newProblems.length; i++) {
IProblem problem = newProblems[i];
if (problem.isError())
result.addEntry(
new RefactoringStatusEntry(
(problem.isError() ? RefactoringStatus.ERROR : RefactoringStatus.WARNING),
problem.getMessage(),
new JavaStringStatusContext(newCuSource, SourceRangeFactory.create(problem))));
}
}
示例6: checkMethodDeclaration
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private void checkMethodDeclaration(RefactoringStatus result, int severity) {
MethodDeclaration methodDeclaration = fSourceProvider.getDeclaration();
// it is not allowed to inline constructor invocation only if it is used for class instance
// creation
// if constructor is invoked from another constructor then we can inline such invocation
if (fInvocation.getNodeType() != ASTNode.CONSTRUCTOR_INVOCATION
&& methodDeclaration.isConstructor()) {
result.addEntry(
new RefactoringStatusEntry(
severity,
RefactoringCoreMessages.CallInliner_constructors,
JavaStatusContext.create(fCUnit, fInvocation)));
}
if (fSourceProvider.hasSuperMethodInvocation()
&& fInvocation.getNodeType() == ASTNode.METHOD_INVOCATION) {
Expression receiver = ((MethodInvocation) fInvocation).getExpression();
if (receiver instanceof ThisExpression) {
result.addEntry(
new RefactoringStatusEntry(
severity,
RefactoringCoreMessages.CallInliner_super_into_this_expression,
JavaStatusContext.create(fCUnit, fInvocation)));
}
}
}
示例7: checkSource
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private void checkSource(SubProgressMonitor monitor, RefactoringStatus result)
throws CoreException {
String newCuSource = fChange.getPreviewContent(new NullProgressMonitor());
CompilationUnit newCUNode =
new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL)
.parse(newCuSource, fCu, true, true, monitor);
IProblem[] newProblems =
RefactoringAnalyzeUtil.getIntroducedCompileProblems(newCUNode, fCuRewrite.getRoot());
for (int i = 0; i < newProblems.length; i++) {
IProblem problem = newProblems[i];
if (problem.isError())
result.addEntry(
new RefactoringStatusEntry(
(problem.isError() ? RefactoringStatus.ERROR : RefactoringStatus.WARNING),
problem.getMessage(),
new JavaStringStatusContext(newCuSource, SourceRangeFactory.create(problem))));
}
}
示例8: addError
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private static RefactoringStatusEntry addError(RefactoringStatus status, IMethod sourceMethod,
PreconditionFailure failure, IMember member, IMember... more) {
List<String> elementNames = new ArrayList<>();
elementNames.add(getElementLabel(member, ALL_FULLY_QUALIFIED));
Stream<String> stream = Arrays.asList(more).parallelStream().map(m -> getElementLabel(m, ALL_FULLY_QUALIFIED));
Stream<String> concat = Stream.concat(elementNames.stream(), stream);
List<String> collect = concat.collect(Collectors.toList());
status.addEntry(RefactoringStatus.ERROR, MessageFormat.format(failure.getMessage(), collect.toArray()),
JavaStatusContext.create(member),
MigrateSkeletalImplementationToInterfaceRefactoringDescriptor.REFACTORING_ID, failure.ordinal(),
sourceMethod);
return getLastRefactoringStatusEntry(status);
}
开发者ID:ponder-lab,项目名称:Migrate-Skeletal-Implementation-to-Interface-Refactoring,代码行数:16,代码来源:MigrateSkeletalImplementationToInterfaceRefactoringProcessor.java
示例9: addEntry
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private void addEntry(RefactoringStatus result, String message, int code, int severity) {
result.addEntry(
new RefactoringStatusEntry(
severity,
message,
JavaStatusContext.create(fCUnit, fInvocation),
Corext.getPluginId(),
code,
null));
}
示例10: checkAccessedFields
import org.eclipse.ltk.core.refactoring.RefactoringStatus; //导入方法依赖的package包/类
private RefactoringStatus checkAccessedFields(IMethod sourceMethod, final Optional<IProgressMonitor> monitor,
final ITypeHierarchy destinationInterfaceSuperTypeHierarchy) throws CoreException {
monitor.ifPresent(m -> m.beginTask(RefactoringCoreMessages.PullUpRefactoring_checking_referenced_elements, 2));
final RefactoringStatus result = new RefactoringStatus();
final List<IMember> pulledUpList = Arrays.asList(sourceMethod);
final IField[] accessedFields = ReferenceFinderUtil.getFieldsReferencedIn(new IJavaElement[] { sourceMethod },
new SubProgressMonitor(monitor.orElseGet(NullProgressMonitor::new), 1));
final IType destination = getDestinationInterface(sourceMethod).orElseThrow(() -> new IllegalArgumentException(
"Source method: " + sourceMethod + " has no destiantion interface."));
for (IField accessedField : accessedFields) {
if (!accessedField.exists())
continue;
boolean isAccessible = pulledUpList.contains(accessedField) || canBeAccessedFrom(sourceMethod,
accessedField, destination, destinationInterfaceSuperTypeHierarchy)
|| Flags.isEnum(accessedField.getFlags());
if (!isAccessible) {
final String message = org.eclipse.jdt.internal.corext.util.Messages.format(
PreconditionFailure.FieldNotAccessible.getMessage(),
new String[] {
JavaElementLabels.getTextLabel(accessedField, JavaElementLabels.ALL_FULLY_QUALIFIED),
JavaElementLabels.getTextLabel(destination, JavaElementLabels.ALL_FULLY_QUALIFIED) });
result.addEntry(RefactoringStatus.ERROR, message, JavaStatusContext.create(accessedField),
MigrateSkeletalImplementationToInterfaceRefactoringDescriptor.REFACTORING_ID,
PreconditionFailure.FieldNotAccessible.ordinal(), sourceMethod);
this.getUnmigratableMethods().add(sourceMethod);
} else if (!JdtFlags.isStatic(accessedField) && !accessedField.getDeclaringType().isInterface()) {
// it's accessible and it's an instance field.
// Let's decide if the source method is accessing it from this
// object or another. If it's from this object, we fail.
// First, find all references of the accessed field in the
// source method.
FieldAccessAnalysisSearchRequestor requestor = new FieldAccessAnalysisSearchRequestor(this, monitor);
this.getSearchEngine().search(
SearchPattern.createPattern(accessedField, IJavaSearchConstants.REFERENCES,
SearchPattern.R_EXACT_MATCH),
new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() },
SearchEngine.createJavaSearchScope(new IJavaElement[] { sourceMethod }), requestor,
new SubProgressMonitor(monitor.orElseGet(NullProgressMonitor::new), IProgressMonitor.UNKNOWN));
if (requestor.hasAccessesToFieldsFromImplicitParameter())
addErrorAndMark(result, PreconditionFailure.SourceMethodAccessesInstanceField, sourceMethod,
accessedField);
}
}
monitor.ifPresent(IProgressMonitor::done);
return result;
}
开发者ID:ponder-lab,项目名称:Migrate-Skeletal-Implementation-to-Interface-Refactoring,代码行数:54,代码来源:MigrateSkeletalImplementationToInterfaceRefactoringProcessor.java