org.eclipse.jdt.core.compiler.BuildContext Java Examples

The following examples show how to use org.eclipse.jdt.core.compiler.BuildContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CompPlugin.java    From junion with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
	public void buildStarting(BuildContext[] files, boolean isBatch) {
		super.buildStarting(files, isBatch);
//		try {
//			
//		log("STARTING batch: " + isBatch);
//		
//		for(BuildContext bc : files) {
//			IFile file = bc.getFile();
//			
//			log(file.getName());
//			
//		}
//		if(current != null) {
//			IPackageFragment[] packages = current.getPackageFragments();
//			for (IPackageFragment packageFragment : packages) {
//				for (final ICompilationUnit compilationUnit : packageFragment.getCompilationUnits()) {
//					
//				}
//			}
//			//ICompilationUnit unit = ICompilationUnit.;
//		} 
//		else log("current is null");
//		
//		} catch (CoreException e) {
//			e.printStackTrace();
//		}
	}
 
Example #2
Source File: DebugSourceInstallingCompilationParticipant.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void buildStarting(BuildContext[] files, boolean isBatch) {
	super.buildStarting(files, isBatch);
	if (this.files != null)
		this.files.addAll(Arrays.asList(files));
	else
		this.files = Lists.newArrayList(files);
}
 
Example #3
Source File: JavaCompilationParticipant.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void buildStarting(final BuildContext[] files, boolean isBatch) {
  // We handle batch builds in a separate job to avoid blocking for a long
  // time in the case of batch (clean) builds.
  if (isBatch) {
    assert files.length > 0;
    IProject project = files[0].getFile().getProject();

    synchronized (this) {
      Job job = validationJobs.get(project);
      if (job != null) {
        job.cancel();
      }

      job = new Job("Validating GWT components") {
        @Override
        protected IStatus run(IProgressMonitor monitor) {

          monitor.beginTask("validating", files.length);
          handleBuildStarting(files, monitor);
          monitor.done();

          return new JobStatus(Status.OK, this, "done");
        }
      };

      validationJobs.put(project, job);
      job.schedule();
    }
  } else {
    handleBuildStarting(files, null);
  }
}
 
Example #4
Source File: AbstractJtxtUMLCompilationParticipant.java    From txtUML with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void buildStarting(BuildContext[] files, boolean isBatch) {
	for (BuildContext file : files) {
		IProject project = file.getFile().getProject();
		IJavaProject javaProject = JavaCore.create(project);

		Set<BuildContext> projectFileSet = javaProjectToFileSet.get(javaProject);
		if (projectFileSet == null) {
			projectFileSet = new HashSet<>();
			javaProjectToFileSet.put(javaProject, projectFileSet);
		}

		projectFileSet.add(file);
	}
}
 
Example #5
Source File: AbstractJtxtUMLCompilationParticipant.java    From txtUML with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void buildFinished(IJavaProject javaProject) {
	Set<BuildContext> projectFileSet = javaProjectToFileSet.get(javaProject);
	if (projectFileSet == null) {
		// 'buildFinished' might be called without 'buildStarting'
		return;
	}
	projectFileSet.forEach(f -> validateFile(f, javaProject));
	javaProjectToFileSet.remove(javaProject);
}
 
Example #6
Source File: CompPlugin.java    From junion with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void processAnnotations(BuildContext[] files) {
	super.processAnnotations(files);
	log("Annotation batch: ");
	
}
 
Example #7
Source File: DebugSourceInstallingCompilationParticipant.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void buildFinished(IJavaProject project) {
	StoppedTask task = Stopwatches.forTask("DebugSourceInstallingCompilationParticipant.install");
	try {
		task.start();
		super.buildFinished(project);
		if (files == null)
			return;
		for (BuildContext ctx : files) {
			try {
				IFile generatedJavaFile = ctx.getFile();

				// This may fail if there is no trace file.
				IEclipseTrace traceToSource = traceInformation.getTraceToSource(generatedJavaFile);
				if (traceToSource == null) {
					continue;
				}
				AbstractTraceRegion rootTraceRegion = findRootTraceRegion(traceToSource);
				if (rootTraceRegion == null)
					continue;

				SourceRelativeURI dslSourceFile = rootTraceRegion.getAssociatedSrcRelativePath();

				// OutputConfigurations are only available for folders targeted by Xtext's code generation.
				OutputConfiguration outputConfiguration = findOutputConfiguration(dslSourceFile, generatedJavaFile);
				if (outputConfiguration == null)
					continue;

				IJavaElement element = JavaCore.create(generatedJavaFile);
				if (element == null)
					continue;

				deleteTaskMarkers(generatedJavaFile);
				markerReflector.reflectErrorMarkerInSource(generatedJavaFile, traceToSource);

				ITraceToBytecodeInstaller installer = getInstaller(outputConfiguration);
				installer.setTrace(generatedJavaFile.getName(), rootTraceRegion);
				for (IFile javaClassFile : findGeneratedJavaClassFiles(element)) {
					InputStream contents = javaClassFile.getContents();
					try {
						byte[] byteCode = installer.installTrace(ByteStreams.toByteArray(contents));
						if (byteCode != null) {
							javaClassFile.setContents(new ByteArrayInputStream(byteCode), 0, null);
						} else {
							// we need to touch the class file to do a respin of the build
							// otherwise a needsRebuild request is ignored since no IResourceDelta is available
							javaClassFile.touch(null);
						}
					} finally {
						contents.close();
					}
				}
			} catch (Exception e) {
				String msg = "Could not process %s to install source information: %s";
				log.error(String.format(msg, ctx.getFile().getFullPath().toString(), e.getMessage()), e);
			}
		}
	} finally {
		files = null;
		task.stop();
	}
}