Example usage for com.google.gwt.eclipse.core.markers GWTJavaProblem MARKER_ID

List of usage examples for com.google.gwt.eclipse.core.markers GWTJavaProblem MARKER_ID

Introduction

In this page you can find the example usage for com.google.gwt.eclipse.core.markers GWTJavaProblem MARKER_ID.

Prototype

String MARKER_ID

To view the source code for com.google.gwt.eclipse.core.markers GWTJavaProblem MARKER_ID.

Click Source Link

Usage

From source file:com.google.gdt.eclipse.appengine.rpc.validators.JavaCompilationParticipant.java

License:Open Source License

@Override
public void reconcile(ReconcileContext context) {

    ICompilationUnit cu = context.getWorkingCopy();

    IType requestContext = null;/*from  ww w  .  ja va 2  s . c o m*/

    try {
        if (!cu.isConsistent()) {
            cu.reconcile(AST.JLS3, true, null, null);
            assert (cu.isConsistent());
        }

        // find the requestfactory classes, once per project
        if (javaProject == null || javaProject.getProject() != cu.getJavaProject().getProject()) {

            javaProject = cu.getJavaProject();
            projectEntities.clear();
            proxies.clear();
            requestMap.clear();
            RequestFactoryUtils.findAllTypes(javaProject, projectEntities, proxies, requestMap);
        }

        if (cu.findPrimaryType() == null) {
            return;
        }
        if (cuName == null || !cuName.equals(cu.findPrimaryType().getFullyQualifiedName())) {
            cuName = cu.findPrimaryType().getFullyQualifiedName();

            if (requestMap.containsKey(cuName)) {
                requestContext = requestMap.get(cuName);
            } else {
                requestContext = null;
            }
            // if there is no requestfactory implementation, no need to validate
        }
        if (requestContext != null) {
            CompilationUnit ast = context.getAST3();
            ArrayList<CategorizedProblem> finalProblemSet = new ArrayList<CategorizedProblem>();
            CategorizedProblem[] currentProblems = context.getProblems(GWTJavaProblem.MARKER_ID);
            if (currentProblems != null) {
                finalProblemSet.addAll(Arrays.asList(currentProblems));
            }
            RequestFactoryValidator validator = new RequestFactoryValidator(requestContext, projectEntities,
                    proxies);
            List<CategorizedProblem> reqFactoryProblems = validator.validate(ast);
            finalProblemSet.addAll(reqFactoryProblems);
            context.putProblems(GWTJavaProblem.MARKER_ID,
                    (finalProblemSet.size() > 0 ? finalProblemSet.toArray(EMPTY_PROBLEMS) : null));
        }
    } catch (JavaModelException e) {
        AppEngineRPCPlugin.log(e);
    }
}