当前位置: 首页>>代码示例>>Java>>正文


Java IMarker.SEVERITY_ERROR属性代码示例

本文整理汇总了Java中org.eclipse.core.resources.IMarker.SEVERITY_ERROR属性的典型用法代码示例。如果您正苦于以下问题:Java IMarker.SEVERITY_ERROR属性的具体用法?Java IMarker.SEVERITY_ERROR怎么用?Java IMarker.SEVERITY_ERROR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.eclipse.core.resources.IMarker的用法示例。


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

示例1: shouldGenerate

private boolean shouldGenerate(Resource resource, IProject aProject) {
	try {
		Iterable<Pair<IStorage, IProject>> storages = storage2UriMapper.getStorages(resource.getURI());
		for (Pair<IStorage, IProject> pair : storages) {
			if (pair.getFirst() instanceof IFile && pair.getSecond().equals(aProject)) {
				IFile file = (IFile) pair.getFirst();
				int findMaxProblemSeverity = file.findMaxProblemSeverity(null, true, IResource.DEPTH_INFINITE);
				// If the generator itself placed an error marker on the resource, we have to ignore that error.
				// Easiest way here is to remove that error marker-type and look for other severe errors once more:
				if (findMaxProblemSeverity == IMarker.SEVERITY_ERROR) {
					// clean
					GeneratorMarkerSupport generatorMarkerSupport = injector
							.getInstance(GeneratorMarkerSupport.class);
					generatorMarkerSupport.deleteMarker(resource);
					// and recompute:
					findMaxProblemSeverity = file.findMaxProblemSeverity(null, true, IResource.DEPTH_INFINITE);
				}
				// the final decision to build:
				return findMaxProblemSeverity != IMarker.SEVERITY_ERROR;
			}
		}
		return false;
	} catch (CoreException exc) {
		throw new WrappedException(exc);
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:26,代码来源:BuildInstruction.java

示例2: createMarker

@Override
public void createMarker(Resource res, String message, Severity severity) {

	final int severityEclipse;
	switch (severity) {
	case INFO:
		severityEclipse = IMarker.SEVERITY_INFO;
		break;
	case WARNING:
		severityEclipse = IMarker.SEVERITY_WARNING;
		break;
	default:
		severityEclipse = IMarker.SEVERITY_ERROR;
		break;
	}

	try {
		IMarker marker = toIFile(res).createMarker(MARKER__ORG_ECLIPSE_IDE_N4JS_UI_COMPILER_ERROR);
		marker.setAttribute(IMarker.MESSAGE, message);
		marker.setAttribute(IMarker.SEVERITY, severityEclipse);
		marker.setAttribute(IMarker.LINE_NUMBER, 1);
	} catch (CoreException e) {
		LOGGER.error(e.getStatus());
		String resInfo = "";
		if (res != null) {
			if (res.getURI() != null) {
				resInfo = "on resource with uri=" + res.getURI();
			} else {
				resInfo = "on resource=" + res;
			}
		}
		throw new RuntimeException("Cannot create error marker with message='" + message + "' " + resInfo + ".", e);
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:34,代码来源:GeneratorMarkerSupport.java

示例3: report

@Override
public void report(CheckLevel level, JSError error) {
	int imLevel;
	switch (level) {
	case ERROR:
		imLevel = IMarker.SEVERITY_ERROR;
		break;
	case WARNING:
		imLevel = IMarker.SEVERITY_WARNING;
		break;
	default:
		return;
	}
	builder().addMarker(file, error.description, error.getLineNumber(), imLevel);
}
 
开发者ID:mnlipp,项目名称:EclipseMinifyBuilder,代码行数:15,代码来源:GccMinifier.java

示例4: setTitleImageDependingOnSeverity

void setTitleImageDependingOnSeverity(int severity) {
	if (severity == IMarker.SEVERITY_ERROR) {
		setTitleImage(EclipseUtil.getImage("icons/batch-editor-with-error.png", BatchEditorActivator.PLUGIN_ID));
	} else {
		setTitleImage(EclipseUtil.getImage("icons/batch-editor.png", BatchEditorActivator.PLUGIN_ID));
	}
}
 
开发者ID:de-jcup,项目名称:eclipse-batch-editor,代码行数:7,代码来源:BatchEditor.java

示例5: getTitleImageName

private String getTitleImageName(int severity) {
	switch (severity) {
	case IMarker.SEVERITY_ERROR:
		return "bash-editor-with-error.png";
	case IMarker.SEVERITY_WARNING:
		return "bash-editor-with-warning.png";
	case IMarker.SEVERITY_INFO:
		return "bash-editor-with-info.png";
	default:
		return "bash-editor.png";
	}
}
 
开发者ID:de-jcup,项目名称:eclipse-bash-editor,代码行数:12,代码来源:BashEditor.java

示例6: getSeverityLevel

public static int getSeverityLevel(String severity)  {
	String temp = severity.trim();
	if (temp.equalsIgnoreCase("E")) {
		return IMarker.SEVERITY_ERROR;
	} else {
		if (temp.equalsIgnoreCase("W")) {
			return IMarker.SEVERITY_WARNING;
		} else {
			if (temp.equalsIgnoreCase("I")) {
				return IMarker.SEVERITY_INFO;
			} 
		}
	}
	return -1;	
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:15,代码来源:BuildPolicy.java

示例7: build

/**
 * Start a build on given project or workspace using given options.
 * 
 * @param javaProject Project which must be (full) build or null if all
 * workspace has to be built.
 * @param options Options used while building
 */
void build(final IJavaProject javaProject, Hashtable options, boolean noWarning) throws IOException, CoreException {
  if (DEBUG)
    System.out.print("\tstart build...");
  JavaCore.setOptions(options);
  if (PRINT)
    System.out.println("JavaCore options: " + options);

  // Build workspace if no project
  if (javaProject == null) {
    // single measure
    ENV.fullBuild();
  } else {
    if (PRINT)
      System.out.println("Project options: " + javaProject.getOptions(false));
    IWorkspaceRunnable compilation = new IWorkspaceRunnable() {
      public void run(IProgressMonitor monitor) throws CoreException {
        ENV.fullBuild(javaProject.getPath());
      }
    };
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    workspace.run(compilation, null/* don't take any lock */, IWorkspace.AVOID_UPDATE, null/*
                                                                                            * no
                                                                                            * progress
                                                                                            * available
                                                                                            * here
                                                                                            */);
  }

  // Verify markers
  IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
  IMarker[] markers = workspaceRoot.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
  List resources = new ArrayList();
  List messages = new ArrayList();
  int warnings = 0;
  for (int i = 0, length = markers.length; i < length; i++) {
    IMarker marker = markers[i];
    switch (((Integer) marker.getAttribute(IMarker.SEVERITY)).intValue()) {
    case IMarker.SEVERITY_ERROR:
      resources.add(marker.getResource().getName());
      messages.add(marker.getAttribute(IMarker.MESSAGE));
      break;
    case IMarker.SEVERITY_WARNING:
      warnings++;
      if (noWarning) {
        resources.add(marker.getResource().getName());
        messages.add(marker.getAttribute(IMarker.MESSAGE));
      }
      break;
    }
  }
  workspaceRoot.deleteMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);

  // Assert result
  int size = messages.size();
  if (size > 0) {
    StringBuffer debugBuffer = new StringBuffer();
    for (int i = 0; i < size; i++) {
      debugBuffer.append(resources.get(i));
      debugBuffer.append(":\n\t");
      debugBuffer.append(messages.get(i));
      debugBuffer.append('\n');
    }
    System.out.println("Unexpected ERROR marker(s):\n" + debugBuffer.toString());
    System.out.println("--------------------");
    String target = javaProject == null ? "workspace" : javaProject.getElementName();
    // assertEquals("Found "+size+" unexpected errors while building "+target,
    // 0, size);
  }
  if (DEBUG)
    System.out.println("done");
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:78,代码来源:FullSourceWorkspaceBuildTests.java

示例8: getSeverity

public static int getSeverity(org.ec4j.core.parser.ErrorEvent.ErrorType errorType) {
	return errorType.isSyntaxError() ?  IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING;
}
 
开发者ID:angelozerr,项目名称:ec4e,代码行数:3,代码来源:MarkerUtils.java

示例9: visit

/**
 * Answers whether children should be visited.
 * <p>
 * If the associated resource is a class file which has been changed, record it.
 * </p>
 */
@Override
public boolean visit(IResourceDelta delta) {
    if (delta == null || 0 == (delta.getKind() & IResourceDelta.CHANGED)) {
        return false;
    }
    IResource resource = delta.getResource();
    if (resource != null) {
        switch (resource.getType()) {
            case IResource.FILE:
                if (0 == (delta.getFlags() & IResourceDelta.CONTENT)) {
                    return false;
                }
                if (CLASS_FILE_EXTENSION.equals(resource.getFullPath().getFileExtension())) {
                    IPath localLocation = resource.getLocation();
                    if (localLocation != null) {
                        String path = localLocation.toOSString();
                        IClassFileReader reader = ToolFactory.createDefaultClassFileReader(path,
                                IClassFileReader.CLASSFILE_ATTRIBUTES);
                        if (reader != null) {
                            // this name is slash-delimited
                            String qualifiedName = new String(reader.getClassName());
                            boolean hasBlockingErrors = false;
                            try {
                                // If the user doesn't want to replace
                                // classfiles containing
                                // compilation errors, get the source
                                // file associated with
                                // the class file and query it for
                                // compilation errors
                                IJavaProject pro = JavaCore.create(resource.getProject());
                                ISourceAttribute sourceAttribute = reader.getSourceFileAttribute();
                                String sourceName = null;
                                if (sourceAttribute != null) {
                                    sourceName = new String(sourceAttribute.getSourceFileName());
                                }
                                IResource sourceFile = getSourceFile(pro, qualifiedName, sourceName);
                                if (sourceFile != null) {
                                    IMarker[] problemMarkers = null;
                                    problemMarkers = sourceFile.findMarkers(
                                            IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true,
                                            IResource.DEPTH_INFINITE);
                                    for (IMarker problemMarker : problemMarkers) {
                                        if (problemMarker.getAttribute(IMarker.SEVERITY,
                                                -1) == IMarker.SEVERITY_ERROR) {
                                            hasBlockingErrors = true;
                                            break;
                                        }
                                    }
                                }
                            } catch (CoreException e) {
                                logger.log(Level.SEVERE, "Failed to visit classes: " + e.getMessage(), e);
                            }
                            if (!hasBlockingErrors) {
                                changedFiles.add(resource);
                                // dot-delimit the name
                                fullyQualifiedNames.add(qualifiedName.replace('/', '.'));
                            }
                        }
                    }
                }
                return false;

            default:
                return true;
        }
    }
    return true;
}
 
开发者ID:Microsoft,项目名称:java-debug,代码行数:74,代码来源:JavaHotCodeReplaceProvider.java


注:本文中的org.eclipse.core.resources.IMarker.SEVERITY_ERROR属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。