本文整理汇总了Java中org.eclipse.wst.validation.internal.provisional.core.IReporter类的典型用法代码示例。如果您正苦于以下问题:Java IReporter类的具体用法?Java IReporter怎么用?Java IReporter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IReporter类属于org.eclipse.wst.validation.internal.provisional.core包,在下文中一共展示了IReporter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validate
import org.eclipse.wst.validation.internal.provisional.core.IReporter; //导入依赖的package包/类
/**
* Validates a given {@link IDocument} if the project has the App Engine Standard facet.
*/
@Override
public void validate(IValidationContext helper, IReporter reporter) throws ValidationException {
IProject project = getProject(helper);
try {
IFacetedProject facetedProject = ProjectFacetsManager.create(project);
if (AppEngineStandardFacet.hasFacet(facetedProject)) {
String encoding = getDocumentEncoding(document);
byte[] bytes = document.get().getBytes(encoding);
IFile source = getFile(helper);
validate(reporter, source, bytes);
}
} catch (IOException | CoreException ex) {
logger.log(Level.SEVERE, ex.getMessage());
}
}
示例2: validate
import org.eclipse.wst.validation.internal.provisional.core.IReporter; //导入依赖的package包/类
private List validate(String html) throws CoreException {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("test");
if (!project.exists()) {
project.create(new NullProgressMonitor());
project.open(new NullProgressMonitor());
}
// Add tsconfig.json in order to the project has angular nature
IFile tsconfigJson = project.getFile("tsconfig.json");
if (!tsconfigJson.exists()) {
tsconfigJson.create(IOUtils.toInputStream("{}"), 1, new NullProgressMonitor());
}
IFile file = project.getFile("test.html");
if (file.exists()) {
file.setContents(IOUtils.toInputStream(html), 1, new NullProgressMonitor());
} else {
file.create(IOUtils.toInputStream(html), 1, new NullProgressMonitor());
}
HTMLValidator validator = new HTMLValidator();
ValidationResult result = validator.validate(file, 1, new ValidationState(), new NullProgressMonitor());
IReporter reporter = result.getReporter(new NullProgressMonitor());
return reporter.getMessages();
}
示例3: validate
import org.eclipse.wst.validation.internal.provisional.core.IReporter; //导入依赖的package包/类
public static void validate(IIDETypeScriptFile tsFile, IReporter reporter, IValidator validator) {
try {
IIDETypeScriptProject tsProject = (IIDETypeScriptProject) tsFile.getProject();
TypeScriptReporterCollector collector = new TypeScriptReporterCollector(tsFile, reporter, validator);
if (tsProject.canSupport(CommandNames.SemanticDiagnosticsSync)) {
boolean includeLinePosition = !tsProject.canSupport(CommandCapability.DiagnosticWithCategory);
addDiagnostics(tsFile.semanticDiagnosticsSync(includeLinePosition), collector);
addDiagnostics(tsFile.syntacticDiagnosticsSync(includeLinePosition), collector);
} else {
List<DiagnosticEvent> events = tsFile.geterr().get(5000, TimeUnit.MILLISECONDS);
for (DiagnosticEvent event : events) {
addDiagnostics(event.getBody(), collector);
}
}
} catch (Throwable e) {
Trace.trace(Trace.SEVERE, "Error while TypeScript validation.", e);
}
}
示例4: createMissingTagError
import org.eclipse.wst.validation.internal.provisional.core.IReporter; //导入依赖的package包/类
private static void createMissingTagError(Token token, boolean isStartTag,
IReporter reporter, int tagErrorCount, Stack<Token> tagStack,
IValidator validator, ISeverityProvider provider) {
boolean isArray = (token.type == JSONRegionContexts.JSON_ARRAY_OPEN || token.type == JSONRegionContexts.JSON_ARRAY_CLOSE);
Object[] args = { token.text };
String messageText = NLS.bind(getMessage(isStartTag, isArray), args);
LocalizedMessage message = createMessage(token, messageText,
JSONCorePreferenceNames.MISSING_BRACKET, provider);
Object fixInfo = /*
* isStartTag ? (Object) getStartEndFixInfo(token.text,
* token) :
*/token.text;
getAnnotationMsg(reporter,
isStartTag ? ProblemIDsJSON.MissingEndBracket
: ProblemIDsJSON.MissingStartBracket, message, fixInfo,
token.length, validator);
if (++tagErrorCount > ERROR_THRESHOLD) {
tagStack.clear();
}
}
示例5: validate
import org.eclipse.wst.validation.internal.provisional.core.IReporter; //导入依赖的package包/类
@Override
public void validate(IValidationContext helper, IReporter reporter)
throws ValidationException {
final String[] uris = helper.getURIs();
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
if (uris.length > 0) {
IFile currentFile = null;
for (int i = 0; i < uris.length && !reporter.isCancelled(); i++) {
// might be called with just project path?
IPath path = new Path(uris[i]);
if (path.segmentCount() > 1) {
currentFile = root.getFile(path);
if (shouldValidate(currentFile, true)) {
validateFile(currentFile, reporter);
}
} else if (uris.length == 1) {
validateProject(helper, reporter);
}
}
} else
validateProject(helper, reporter);
}
示例6: validateProject
import org.eclipse.wst.validation.internal.provisional.core.IReporter; //导入依赖的package包/类
private void validateProject(IValidationContext helper,
final IReporter reporter) {
// if uris[] length 0 -> validate() gets called for each project
if (helper instanceof IWorkbenchContext) {
IProject project = ((IWorkbenchContext) helper).getProject();
IResourceProxyVisitor visitor = new IResourceProxyVisitor() {
public boolean visit(IResourceProxy proxy) throws CoreException {
if (shouldValidate(proxy)) {
validateFile((IFile) proxy.requestResource(), reporter);
}
return true;
}
};
try {
// collect all jsp files for the project
project.accept(visitor, IResource.DEPTH_INFINITE);
} catch (CoreException e) {
Logger.logException(e);
}
}
}
示例7: executeMarkupValidator
import org.eclipse.wst.validation.internal.provisional.core.IReporter; //导入依赖的package包/类
private IReporter executeMarkupValidator(String uri) {
Path path = new Path(uri);
String fileProtocol = "file://"; //$NON-NLS-1$
int index = uri.indexOf(fileProtocol);
IFile resource = null;
if (index == 0) {
String transformedUri = uri.substring(fileProtocol.length());
Path transformedPath = new Path(transformedUri);
resource = ResourcesPlugin.getWorkspace().getRoot()
.getFileForLocation(transformedPath);
} else {
resource = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
}
IReporter reporter = null;
if (resource != null) {
reporter = val.validate(resource, 0, new ValOperation().getState());
}
return reporter;
}
示例8: validateResultMapId
import org.eclipse.wst.validation.internal.provisional.core.IReporter; //导入依赖的package包/类
private void validateResultMapId(IJavaProject project, IFile file, IDOMDocument doc,
ValidationResult result, IDOMAttr attr, String attrValue, IReporter reporter)
throws JavaModelException, XPathExpressionException
{
if (attrValue.indexOf(',') == -1)
{
validateReference(project, file, doc, result, attr, attrValue, "resultMap", reporter);
}
else
{
String[] resultMapArr = attrValue.split(",");
for (String resultMapRef : resultMapArr)
{
String ref = resultMapRef.trim();
if (ref.length() > 0)
{
validateReference(project, file, doc, result, attr, ref, "resultMap", reporter);
}
}
}
}
示例9: validateDelta
import org.eclipse.wst.validation.internal.provisional.core.IReporter; //导入依赖的package包/类
private void validateDelta(IValidationContext helper, IReporter reporter) {
String[] deltaArray = helper.getURIs();
for (int i = 0; i < deltaArray.length; i++) {
String delta = deltaArray[i];
if (delta == null)
continue;
if (reporter != null) {
IMessage message = new LocalizedMessage(IMessage.LOW_SEVERITY,
delta.substring(1));
reporter.displaySubtask(this, message);
}
IResource resource = getResource(delta);
if (resource == null || !(resource instanceof IFile))
continue;
validateFile(helper, reporter, (IFile) resource, null);
}
}
示例10: validateContainer
import org.eclipse.wst.validation.internal.provisional.core.IReporter; //导入依赖的package包/类
private void validateContainer(IValidationContext helper,
IReporter reporter, IContainer container) {
try {
IResource[] resourceArray = container.members(false);
for (int i = 0; i < resourceArray.length; i++) {
IResource resource = resourceArray[i];
if (resource == null || reporter.isCancelled())
continue;
if (resource instanceof IFile) {
IMessage message = new LocalizedMessage(
IMessage.LOW_SEVERITY, resource.getFullPath()
.toString().substring(1));
reporter.displaySubtask(this, message);
validateFile(helper, reporter, (IFile) resource, null);
} else if (resource instanceof IContainer) {
validateContainer(helper, reporter, (IContainer) resource);
}
}
} catch (CoreException ex) {
}
}
示例11: validateFile
import org.eclipse.wst.validation.internal.provisional.core.IReporter; //导入依赖的package包/类
protected void validateFile(IValidationContext helper, IReporter reporter,
IFile file, ValidationResult result) {
if ((reporter != null) && (reporter.isCancelled() == true)) {
throw new OperationCanceledException();
}
if (!shouldValidate(file)) {
return;
}
IDOMModel model = getModel(file.getProject(), file);
if (model == null)
return;
try {
Collection dependencies = null;
NodeImpl document = null;
if (model.getDocument() instanceof NodeImpl) {
document = (NodeImpl) model.getDocument();
}
validate(reporter, file, model);
} finally {
releaseModel(model);
}
}
示例12: validateImage
import org.eclipse.wst.validation.internal.provisional.core.IReporter; //导入依赖的package包/类
/**
* Validate img/@src
*
* @param documentRegion
* @param reporter
* @param model
* @param file
* @param factory
* @param attrValueRegion
* @param resourceType
*/
private void validateImage(IStructuredDocumentRegion documentRegion,
IReporter reporter, IStructuredModel model, IFile file,
MessageFactory factory, WebResourcesTextRegion attrValueRegion,
WebResourcesFinderType resourceType) {
IDOMAttr attr = DOMHelper.getAttrByOffset(model,
documentRegion.getStartOffset()
+ attrValueRegion.getRegion().getStart());
if (attr != null) {
String attrValue = DOMHelper.getAttrValue(documentRegion
.getText(attrValueRegion.getRegion()));
if (URIHelper.isDataURIScheme(attrValue)) {
// see https://en.wikipedia.org/wiki/Data_URI_scheme
// ex : <img
// src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="
// alt="Red dot" />
// TODO : validate format of data uri scheme.
} else {
// ex : <img src="path/to/image.png" />
validateFile(documentRegion, reporter, model, file, factory,
attrValueRegion, resourceType);
}
}
}
示例13: createMessage
import org.eclipse.wst.validation.internal.provisional.core.IReporter; //导入依赖的package包/类
/**
* Creates a message from a given {@link BannedElement}.
*/
void createMessage(IReporter reporter, BannedElement element, int elementOffset) {
IMessage message = new LocalizedMessage(element.getIMessageSeverity(), element.getMessage());
message.setTargetObject(this);
message.setMarkerId(element.getMarkerId());
message.setLineNo(element.getStart().getLineNumber());
message.setOffset(elementOffset);
message.setLength(element.getLength());
message.setAttribute(IQuickAssistProcessor.class.getName(), element.getQuickAssistProcessor());
reporter.addMessage(this, message);
}
示例14: validate
import org.eclipse.wst.validation.internal.provisional.core.IReporter; //导入依赖的package包/类
@Override
public void validate(IValidationContext helper, IReporter reporter) throws ValidationException {
if (helper == null || document == null) {
return;
}
if ((reporter != null) && (reporter.isCancelled() == true)) {
throw new OperationCanceledException();
}
// we cannot use helper#getURI() to retrieve the IFile which is
// validating, because
// this helper is filled by using IStructuredModel (see
// ReconcileStepForValidator#getFile())
// and JSDT JavaScript Editor doesn't manage IStructuredModel
IFile file = TypeScriptResourceUtil.getFile(document);
if (file == null || !TypeScriptResourceUtil.canConsumeTsserver(file)) {
return;
}
try {
IIDETypeScriptProject tsProject = TypeScriptResourceUtil.getTypeScriptProject(file.getProject());
IIDETypeScriptFile tsFile = tsProject.openFile(file, document);
TypeScriptValidationHelper.validate(tsFile, reporter, this);
} catch (Exception e) {
Trace.trace(Trace.SEVERE, "Error while TypeScript validation.", e);
}
}
示例15: validate
import org.eclipse.wst.validation.internal.provisional.core.IReporter; //导入依赖的package包/类
@Override
public ValidationResult validate(IResource resource, int kind,
ValidationState state, IProgressMonitor monitor) {
if (resource.getType() != IResource.FILE)
return null;
ValidationResult result = new ValidationResult();
IReporter reporter = result.getReporter(monitor);
try {
validateDockerFile((IFile) resource, reporter, result);
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}