/* (non-Javadoc) * @see com.aptana.ide.core.ftp.BaseFTPConnectionFileManager#changeFilePermissions(org.eclipse.core.runtime.IPath, long, org.eclipse.core.runtime.IProgressMonitor) */ @Override protected void changeFilePermissions(IPath path, long permissions, IProgressMonitor monitor) throws CoreException, FileNotFoundException { if (chmodSupported == Boolean.FALSE) { return; } try { IPath dirPath = path.removeLastSegments(1); changeCurrentDir(dirPath); Policy.checkCanceled(monitor); chmodSupported = ftpClient.site( "CHMOD " + Long.toOctalString(permissions) + " " + path.lastSegment()); // $NON-NLS-1$ //$NON-NLS-2$ } catch (FileNotFoundException e) { throw e; } catch (OperationCanceledException e) { throw e; } catch (Exception e) { throw new CoreException( new Status(Status.ERROR, FTPPlugin.PLUGIN_ID, "Set permissions failed", e)); } finally { monitor.done(); } }
private synchronized void checkFile() { if (fActiveEditor == null) return; IEditorInput input = fActiveEditor.getEditorInput(); IPath location = null; if (input instanceof IFileEditorInput) { IFile file = ((IFileEditorInput) input).getFile(); location = file.getLocation(); } else if (input instanceof FileStoreEditorInput) { location = URIUtil.toPath(((FileStoreEditorInput) input).getURI()); } else if (input instanceof CommonSourceNotFoundEditorInput) { Object artifact = ((CommonSourceNotFoundEditorInput) input).getArtifact(); if (artifact instanceof CSourceNotFoundElement) { location = new Path(((CSourceNotFoundElement) artifact).getFile()); } } if (location != null && fExpectedFile != null && location.lastSegment().equals(fExpectedFile.lastSegment())) { fFileFound = true; if (fActiveEditor instanceof ITextEditor) { IDocumentProvider docProvider = ((ITextEditor) fActiveEditor).getDocumentProvider(); fAnnotationModel = docProvider.getAnnotationModel(fActiveEditor.getEditorInput()); fAnnotationModel.addAnnotationModelListener(this); checkAnnotations(); } else if (fActiveEditor instanceof CommonSourceNotFoundEditor) { // No annotation will be painted if source not found. fAnnotationFound = true; } } }
/* (non-Javadoc) * @see com.aptana.ide.core.ftp.BaseFTPConnectionFileManager#setModificationTime(org.eclipse.core.runtime.IPath, long, org.eclipse.core.runtime.IProgressMonitor) */ @Override protected void setModificationTime(IPath path, long modificationTime, IProgressMonitor monitor) throws CoreException, FileNotFoundException { if (!serverSupportsFeature("MFMT") && !serverSupportsFeature("SITE UTIME")) { // $NON-NLS-1$ //$NON-NLS-2$ return; } try { IPath dirPath = path.removeLastSegments(1); changeCurrentDir(dirPath); Policy.checkCanceled(monitor); if (serverSupportsFeature("MFMT")) { // $NON-NLS-1$ ftpClient.setModTime(path.lastSegment(), new Date(modificationTime)); } else if (serverSupportsFeature("SITE UTIME")) { // $NON-NLS-1$ Calendar cal = Calendar.getInstance(); long localTimezoneShift = cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET); Date date = new Date(modificationTime - localTimezoneShift); if (utimeFormat == -1) { for (utimeFormat = 0; utimeFormat < UTIME_FORMATS.length; ++utimeFormat) { String format = UTIME_FORMATS[utimeFormat].format(date); FTPReply reply = ftpClient.sendCommand( "SITE " + MessageFormat.format(format, path.lastSegment())); // $NON-NLS-1$ if (!"500".equals(reply.getReplyCode()) && !"501".equals(reply.getReplyCode())) { // $NON-NLS-1$ //$NON-NLS-2$ break; } } } else if (utimeFormat >= 0 && utimeFormat < UTIME_FORMATS.length) { String format = UTIME_FORMATS[utimeFormat].format(date); ftpClient.site(MessageFormat.format(format, path.lastSegment())); } } } catch (FileNotFoundException e) { throw e; } catch (OperationCanceledException e) { throw e; } catch (Exception e) { throw new CoreException( new Status( Status.ERROR, FTPPlugin.PLUGIN_ID, Messages.FTPConnectionFileManager_set_modification_time_failed, e)); } finally { monitor.done(); } }
/** * Return the IResource instance that matches the specified path. The path is the relative path in * the workspace. If no IResource instance is found that match this path a null is returned. * * @param name the path to the IResource * @return the IResource */ public static IResource findIResourceByPath(final IPath workspacePath) { if (workspacePath == null || workspacePath.isEmpty() || getWorkspace() == null) return null; // Collect all IResources within all IProjects final FileResourceCollectorVisitor visitor = new FileResourceCollectorVisitor(); if (getWorkspace() != null && getWorkspace().getRoot() != null) { final IProject[] projects = getWorkspace().getRoot().getProjects(); for (final IProject project : projects) try { project.accept(visitor); } catch (final CoreException e) { // do nothing } } final IFile[] fileResources = visitor.getFileResources(); for (final IFile fileResource : fileResources) if (fileResource != null) { final IPath path = fileResource.getFullPath(); // Do not process file names staring with '.' since these // are considered reserved for Eclipse specific files if (path.lastSegment().charAt(0) == '.') continue; if (path.equals(workspacePath)) return fileResource; } return null; }
private static IEditorInput getEditorInput(final IErlElement element0) { IErlElement element = element0; final IResource resource = element.getResource(); if (resource instanceof IFile) { IFile file = (IFile) resource; file = resolveFile(file); return new FileEditorInput(file); } String filePath = element.getFilePath(); while (filePath == null) { final IParent parent = element.getParent(); if (parent instanceof IErlElement) { element = (IErlElement) parent; filePath = element.getFilePath(); } else { break; } } if (filePath != null) { final IPath path = new Path(filePath); IFileStore fileStore = EFS.getLocalFileSystem().getStore(path.removeLastSegments(1)); fileStore = fileStore.getChild(path.lastSegment()); final IFileInfo fetchInfo = fileStore.fetchInfo(); if (!fetchInfo.isDirectory() && fetchInfo.exists()) { if (element instanceof IErlModule && element.getParent() instanceof IErlExternal) { return new ErlangExternalEditorInput(fileStore, (IErlModule) element); } return new FileStoreEditorInput(fileStore); } } return null; }
private void writeSavedIndexNamesFile() { BufferedWriter writer = null; try { writer = new BufferedWriter(new FileWriter(savedIndexNamesFile)); writer.write(DiskIndex.SIGNATURE); writer.write('+'); writer.write(getRubyPluginWorkingLocation().toOSString()); writer.write('\n'); Object[] keys = indexStates.keyTable; Object[] states = indexStates.valueTable; for (int i = 0, l = states.length; i < l; i++) { IPath key = (IPath) keys[i]; if (key != null && !key.isEmpty() && states[i] == SAVED_STATE) { writer.write(key.lastSegment()); writer.write('\n'); } } } catch (IOException ignored) { if (VERBOSE) Util.verbose("Failed to write saved index file names", System.err); // $NON-NLS-1$ } finally { if (writer != null) { try { writer.close(); } catch (IOException e) { // ignore } } } }
/* * @see org.eclipse.core.internal.filebuffers.textmanipulation.IFileBufferOperation#run(org.eclipse.core.filebuffers.IFileBuffer, org.eclipse.core.runtime.IProgressMonitor) */ public void run(IFileBuffer fileBuffer, IProgressMonitor progressMonitor) throws CoreException, OperationCanceledException { if (fileBuffer instanceof ITextFileBuffer) { ITextFileBuffer textFileBuffer = (ITextFileBuffer) fileBuffer; IPath path = textFileBuffer.getLocation(); String taskName = path == null ? getOperationName() : path.lastSegment(); progressMonitor = Progress.getMonitor(progressMonitor); progressMonitor.beginTask(taskName, 100); try { IProgressMonitor subMonitor = Progress.getSubMonitor(progressMonitor, 10); MultiTextEditWithProgress edit = computeTextEdit(textFileBuffer, subMonitor); subMonitor.done(); if (edit != null) { Object stateData = startRewriteSession(textFileBuffer); try { subMonitor = Progress.getSubMonitor(progressMonitor, 90); applyTextEdit(textFileBuffer, edit, subMonitor); subMonitor.done(); } finally { stopRewriteSession(textFileBuffer, stateData); } } } finally { progressMonitor.done(); } } }
public static IFile LinkFile(String path) { IWorkspace ws = ResourcesPlugin.getWorkspace(); IProject project = ws.getRoot().getProject("tmp"); if (!project.exists()) try { project.create(null); } catch (CoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (!project.isOpen()) try { project.open(null); } catch (CoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } IPath location = new Path(path); IFile file = project.getFile(location.lastSegment()); try { file.delete(true, null); } catch (CoreException e1) { } try { file.createLink(location, IResource.NONE, null); } catch (CoreException e) { } return file; }
public void performFinish(IProgressMonitor monitor) throws CoreException { IVirtualComponent rootComponent = (IVirtualComponent) getTaskModel().getObject(IReferenceWizardConstants.ROOT_COMPONENT); String runtimeLoc = (String) getTaskModel().getObject(IReferenceWizardConstants.DEFAULT_LIBRARY_LOCATION); if (archives != null && archives.size() > 0) { ArrayList<IVirtualReference> refList = new ArrayList<IVirtualReference>(); Iterator iterator = archives.values().iterator(); while (iterator.hasNext()) { IPath path = (Path) iterator.next(); // IPath fullPath = project.getFile(selected[i]).getFullPath(); String type = VirtualArchiveComponent.LIBARCHIVETYPE + IPath.SEPARATOR; IVirtualComponent archive = ComponentCore.createArchiveComponent( rootComponent.getProject(), type + path.makeRelative().toString()); VirtualReference ref = new VirtualReference(rootComponent, archive); ref.setArchiveName(path.lastSegment()); if (runtimeLoc != null) { ref.setRuntimePath(new Path(runtimeLoc).makeAbsolute()); } refList.add(ref); } IVirtualReference[] finalRefs = refList.toArray(new IVirtualReference[refList.size()]); getTaskModel().putObject(IReferenceWizardConstants.FINAL_REFERENCE, finalRefs); } }
private IFolder addSourceArchive( IPath externalSourceArchivePath, IProject externalSourceArchivesProject, boolean scheduleForCreation) { Map<IPath, IResource> knownSourceArchives = getSourceArchives(); Object existing = knownSourceArchives.get(externalSourceArchivePath); if (existing != null) { return (IFolder) existing; } IFolder result; int counter = 0; do { StringBuilder folderName = new StringBuilder(LINKED_FOLDER_NAME); if (counter > 0) { folderName.append(counter).append('-'); } folderName.append(externalSourceArchivePath.lastSegment()); result = externalSourceArchivesProject.getFolder(folderName.toString()); counter++; } while (result.exists()); if (scheduleForCreation) { synchronized (this) { if (pendingSourceArchives == null) pendingSourceArchives = Collections.synchronizedSet(new HashSet<IPath>()); } pendingSourceArchives.add(externalSourceArchivePath); } knownSourceArchives.put(externalSourceArchivePath, result); return result; }
@Override protected boolean validatePage() { IStatus status = JavaConventions.validateCompilationUnitName( this.getFileName() + ".java", CompilerOptions.VERSION_1_3, CompilerOptions.VERSION_1_3); if (!status.isOK()) { setErrorMessage(status.getMessage()); return false; } IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(getContainerFullPath().segment(0)); // This may need to change depending on how we want to deal with localized components in future. LocatePlugin locatePlugin = LocatePlugin.getDefault(); try { LocalizedComponentsLocateResult result = locatePlugin.getLocalizedComponentsLocateResult(project, getFileName()); if (result.getResources().length > 0) { setErrorMessage("A component by that name already exists"); return false; } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } // Check that we aren't going to create a wocomponent inside another wocomponent IPath path = getContainerFullPath(); if (path.lastSegment().endsWith(".wo")) { setErrorMessage("Cannot create a component within another component"); return false; } return super.validatePage(); }
/** * Returns the java project that corresponds to the given path. Returns null if the path doesn't * correspond to a project. */ private static IJavaProject getJavaProject(IPath path, IJavaModel model) { IJavaProject project = model.getJavaProject(path.lastSegment()); if (project.exists()) { return project; } return null; }
@Override public synchronized void resourceChanged(IResourceChangeEvent event) { IResource res = event.getResource(); if (!(res instanceof IProject)) return; String name = res.getName(); IResourceDelta delta = event.getDelta(); if (delta == null) return; int kind = delta.getKind(); if (configs.containsKey(name)) { if (kind == IResourceDelta.REMOVED) { configs.remove(name); tmpConfigs.remove(name); } else if (kind == IResourceDelta.CHANGED) { int flags = delta.getFlags(); if ((flags & IResourceDelta.MOVED_TO) != 0) { IPath path = delta.getMovedToPath(); Map<String, IAConfiguration> cfgs = configs.get(name); String newName = path.lastSegment(); configs.remove(name); configs.put(newName, cfgs); Map<String, IAConfiguration> tmpcfgs = tmpConfigs.get(name); tmpConfigs.remove(name); tmpConfigs.put(newName, tmpcfgs); } } } }
/* (non-Javadoc) * @see com.aptana.ide.core.ftp.BaseFTPConnectionFileManager#deleteFile(org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IProgressMonitor) */ @Override protected void deleteFile(IPath path, IProgressMonitor monitor) throws CoreException, FileNotFoundException { try { IPath dirPath = path.removeLastSegments(1); changeCurrentDir(dirPath); Policy.checkCanceled(monitor); try { ftpClient.delete(path.lastSegment()); } catch (FTPException e) { System.out.println(e); throw e; } } catch (FileNotFoundException e) { throw e; } catch (OperationCanceledException e) { throw e; } catch (Exception e) { throw new CoreException( new Status( Status.ERROR, FTPPlugin.PLUGIN_ID, StringUtils.format(Messages.FTPConnectionFileManager_deleting_failed, path), e)); } finally { monitor.done(); } }
public static boolean isController(IFile currentFile) { if (currentFile == null) return false; IPath controllerFilePath = currentFile.getProjectRelativePath(); if (controllerFilePath.segmentCount() < 2) return false; return controllerFilePath.segment(controllerFilePath.segmentCount() - 2).equals(CONTROLLERS) && controllerFilePath.lastSegment().endsWith(CONTROLLER_FILE_SUFFIX); }
public boolean isFileExtension(IPath path) { for (int i = 0; i < fileExtensions.length; i++) { if (path.lastSegment().endsWith(fileExtensions[i])) { return true; } } return false; }
public boolean containsAsModule(IPath modulePath) { if (!project.getFullPath().equals(modulePath)) { return false; } String moduleName = modulePath.lastSegment(); List<String> modules = getModules(); return modules.contains(moduleName); }
public static void addServletBridgeFromTarget(final IWARProduct product) { String path = getServletBridgeAbsolutePath(); if (path != null) { IPath absolutePath = new Path(path); IPath relativePath = new Path(absolutePath.lastSegment()); product.addLibrary(relativePath, true); } }
public static String getModelNamePlural(IFile modelFile) { IPath modelFilePath = modelFile.getProjectRelativePath(); String modelFilename = modelFilePath.lastSegment(); if (!CakePHPHelper.isModel(modelFile)) return null; String singular = modelFilename.substring(0, modelFilename.indexOf('.')); String plural = Inflector.pluralize(singular); return plural; }
/** * (non-Javadoc) * * @see org.eclipse.ice.core.iCore.ICore#importFile(java.net.URI, * org.eclipse.core.resources.IProject) */ @Override public void importFile(URI file, IProject project) { // Only do this if the file is good if (file != null) { // Get the file handle IPath path = (new Path(file.toString())); IFile fileInProject = project.getFile(path.lastSegment()); // Get the paths and convert them to strings IPath fullPathInProject = fileInProject.getLocation(); String path1 = path.toString(), path2 = fullPathInProject.toString(); // Remove devices ids and other such things from the path strings path1 = path1.substring(path1.lastIndexOf(":") + 1); path2 = path2.substring(path2.lastIndexOf(":") + 1); // Only manipulate the file if it is not already in the workspace. // It is completely reasonable to stick the file in the workspace // and then "import" it, so a simple check here relieves some // heartburn I would no doubt otherwise endure. if (!path1.equals(path2)) { // If the project space contains a file by the same name, but // with a different absolute path, delete that file. if (fileInProject.exists()) { try { fileInProject.delete(true, null); } catch (CoreException e) { // Complain and don't do anything else. logger.info("Core Message: " + "Unable to import file."); logger.error(getClass().getName() + " Exception!", e); return; } } try { // Open a stream of the file FileInputStream fileStream = new FileInputStream(new File(file)); // Import the file fileInProject.create(fileStream, true, null); } catch (FileNotFoundException e) { // Complain and don't do anything else. logger.info("Core Message: " + "Unable to import file."); logger.error(getClass().getName() + " Exception!", e); return; } catch (CoreException e) { // Complain and don't do anything else. logger.info("Core Message: " + "Unable to import file."); logger.error(getClass().getName() + " Exception!", e); return; } } // Refresh all of the Items itemManager.reloadItemData(); // Drop some debug info. if (System.getProperty("DebugICE") != null) { logger.info("Core Message: " + "Imported file " + file.toString()); } } else { logger.info("File could not be imported into project because the File URI was not valid."); } }
private void create_device_project( final IPath projectPath, final String deviceType, final String lang, final String codegenId, final String templateId, final IProgressMonitor progressMonitor) throws CoreException { final SubMonitor monitor = SubMonitor.convert(progressMonitor, 1); final String projectName = projectPath.lastSegment(); final java.net.URI locationURI = projectPath.toFile().toURI(); final ICodeGeneratorDescriptor code_gen = findCodeGen(lang, codegenId); final ITemplateDesc template = findCodeGenTemplate(templateId, code_gen); // Create the implementation final SoftPkg spd = SpdFactory.eINSTANCE.createSoftPkg(); final Implementation impl = SpdFactory.eINSTANCE.createImplementation(); spd.getImplementation().add(impl); final ImplementationSettings settings = CodegenFactory.eINSTANCE.createImplementationSettings(); initializeSoftPkg(lang, projectName, code_gen, template, spd, impl, settings); final WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { @Override protected void execute(final IProgressMonitor progress_monitor) throws CoreException, InvocationTargetException, InterruptedException { final SubMonitor monitor = SubMonitor.convert(progress_monitor, 2); final IProject project = DeviceProjectCreator.createEmptyProject( projectName, locationURI, monitor.newChild(1)); DeviceProjectCreator.createDeviceFiles( project, spd.getName(), spd.getId(), "", deviceType, false, monitor.newChild(1)); ProjectCreator.addImplementation( project, spd.getName(), impl, settings, monitor.newChild(1)); // Setup the IDL Path ResourceUtils.createIdlLibraryResource(project, monitor.newChild(1)); } }; try { operation.run(monitor.newChild(1)); } catch (final InvocationTargetException e) { throw new CoreException( new Status( IStatus.ERROR, CodegeneratorApplication.PLUGIN_ID, "Failure creating project", e)); } catch (final InterruptedException e) { // pass } }
public CopyComponentDialog( Shell parentShell, String dialogTitle, String dialogMessage, IPath initialValue, IInputValidator validator) { super(parentShell, dialogTitle, dialogMessage, initialValue.lastSegment(), validator); path = initialValue; }
public static IFile getModelFromController(IFile controllerFile) { if (!isController(controllerFile)) return null; IPath controllerFilePath = controllerFile.getProjectRelativePath(); String controllerFilename = controllerFilePath.lastSegment(); IPath model = getModelFromController(controllerFilePath, getModelName(controllerFilename)); IFile file = controllerFile.getProject().getFile(model); return file; }
@Override public IPath getModuleDeployDirectory(IModule module) { final IPath defaultPath = super.getModuleDeployDirectory(module); IPath updatedPath = null; if (defaultPath != null && defaultPath.lastSegment() != null) { final IProject project = module.getProject(); final String requiredSuffix = ProjectUtil.getRequiredSuffix(project); if (requiredSuffix != null && !defaultPath.lastSegment().endsWith(requiredSuffix)) { String lastSegment = defaultPath.lastSegment(); updatedPath = defaultPath.removeLastSegments(1).append(lastSegment + requiredSuffix); } } return updatedPath == null ? defaultPath : updatedPath; }
public static boolean isModel(IFile currentFile) { if (currentFile == null) return false; IPath modelFilePath = currentFile.getProjectRelativePath(); if (modelFilePath.segmentCount() < 2) return false; boolean isModel = modelFilePath.segment(modelFilePath.segmentCount() - 2).equalsIgnoreCase(MODELS) && modelFilePath.lastSegment().endsWith(PHP); return isModel; }
public static String getRunningName(IPath[] paths) { FastStringBuffer buf = new FastStringBuffer(20 * paths.length); for (IPath p : paths) { if (buf.length() > 0) { buf.append(" - "); } buf.append(p.lastSegment()); } return buf.toString(); }
protected void addDependentsOf( IPath path, boolean isStructuralChange, StringSet qualifiedNames, StringSet simpleNames, StringSet rootNames) { path = path.setDevice(null); if (isStructuralChange) { String last = path.lastSegment(); if (last.length() == TypeConstants.PACKAGE_INFO_NAME.length) if (CharOperation.equals(last.toCharArray(), TypeConstants.PACKAGE_INFO_NAME)) { path = path.removeLastSegments( 1); // the package-info file has changed so blame the package itself /* https://bugs.eclipse.org/bugs/show_bug.cgi?id=323785, in the case of default package, there is no need to blame the package itself as there can be no annotations or documentation comment tags in the package-info file that can influence the rest of the package. Just bail out so we don't touch null objects below. */ if (path.isEmpty()) return; } } if (isStructuralChange && !this.hasStructuralChanges) { this.newState.tagAsStructurallyChanged(); this.hasStructuralChanges = true; } // the qualifiedStrings are of the form 'p1/p2' & the simpleStrings are just 'X' rootNames.add(path.segment(0)); String packageName = path.removeLastSegments(1).toString(); boolean wasNew = qualifiedNames.add(packageName); String typeName = path.lastSegment(); int memberIndex = typeName.indexOf('$'); if (memberIndex > 0) typeName = typeName.substring(0, memberIndex); wasNew = simpleNames.add(typeName) | wasNew; if (wasNew && JavaBuilder.DEBUG) System.out.println( " will look for dependents of " //$NON-NLS-1$ + typeName + " in " + packageName); //$NON-NLS-1$ }
public IProject createNewProject(IPath newPath, String name, IProgressMonitor monitor) { IProject newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(name); IWorkspace workspace = ResourcesPlugin.getWorkspace(); final IProjectDescription description = workspace.newProjectDescription(newProject.getName()); description.setLocation(newPath); // run the new project creation operation try { boolean doit = false; if (!newProject.exists()) { // Defect 24558 - Text Importer may result in New Project being created with NO PATH, so // check if NULL // before if (newPath != null && OSPlatformUtil.isWindows()) { // check to see if path exists but case is different IPath path = new Path(FileUiUtils.INSTANCE.getExistingCaseVariantFileName(newPath)); newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(path.lastSegment()); description.setLocation(path); doit = !newProject.exists(); } else { doit = true; } if (doit) { createProject(description, newProject, monitor); } } } catch (CoreException e) { if (e.getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) { MessageDialog.openError( getShell(), ResourceMessages.NewProject_errorMessage, NLS.bind(ResourceMessages.NewProject_caseVariantExistsError, newProject.getName())); } else { ErrorDialog.openError( getShell(), ResourceMessages.NewProject_errorMessage, null, // no special message e.getStatus()); } return null; } catch (Exception theException) { return null; } configureProject(newProject); return newProject; }
/** * Updates the program arguments with a model path, a target folder path, and other Acceleo * arguments. * * @param config is an editable copy of the current launch configuration * @param model is the model path, relative to the workspace * @param target is the target folder path, relative to the workspace * @param args are the Acceleo application arguments (properties) */ public void updateArguments( ILaunchConfigurationWorkingCopy config, String model, String target, String args) { IPath modelPath; if (model != null) { modelPath = new Path(model); } else { modelPath = new Path(""); // $NON-NLS-1$ } if (modelPath.segmentCount() > 1) { modelPath = ResourcesPlugin.getWorkspace().getRoot().getFile(modelPath).getLocation(); } if (modelPath == null) { modelPath = new Path(""); // $NON-NLS-1$ } IPath targetPath; if (target != null) { targetPath = new Path(target); } else { targetPath = new Path(""); // $NON-NLS-1$ } if (targetPath.segmentCount() == 1) { targetPath = ResourcesPlugin.getWorkspace() .getRoot() .getProject(targetPath.lastSegment()) .getLocation(); } else if (targetPath.segmentCount() > 1) { targetPath = ResourcesPlugin.getWorkspace().getRoot().getFolder(targetPath).getLocation(); } if (targetPath == null) { targetPath = new Path(""); // $NON-NLS-1$ } StringBuffer newBuffer = new StringBuffer(); newBuffer.append('"'); newBuffer.append(modelPath.toString()); newBuffer.append("\" \""); // $NON-NLS-1$ newBuffer.append(targetPath.toString()); newBuffer.append('"'); if (args.length() > 0) { StringTokenizer st = new StringTokenizer(args, "\n"); // $NON-NLS-1$ while (st.hasMoreTokens()) { String token = st.nextToken().trim(); newBuffer.append(" \""); // $NON-NLS-1$ newBuffer.append(token); newBuffer.append('"'); } } String newText = newBuffer.toString(); if (!newText.equals(fPrgmArgumentsText.getText())) { fPrgmArgumentsText.setText(newText); config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, newText); } }
private DependsOnOutdatedFileException parseFile( Object tu, AbstractLanguage lang, IIndexFileLocation ifl, IScannerInfo scanInfo, FileContext ctx, IProgressMonitor pm) throws CoreException, InterruptedException { IPath path = getLabel(ifl); Throwable th = null; try { if (fShowActivity) { trace("Indexer: parsing " + path.toOSString()); // $NON-NLS-1$ } pm.subTask( getMessage( MessageKind.parsingFileTask, path.lastSegment(), path.removeLastSegments(1).toString())); FileContent codeReader = fResolver.getCodeReader(tu); final boolean isSource = fResolver.isSourceUnit(tu); long start = System.currentTimeMillis(); IASTTranslationUnit ast = createAST(lang, codeReader, scanInfo, isSource, fASTOptions, ctx, pm); fStatistics.fParsingTime += System.currentTimeMillis() - start; if (ast != null) { // Give the new AST a chance to recognize its translation unit before it is written // to the index. ((ASTTranslationUnit) ast).setOriginatingTranslationUnit((ITranslationUnit) tu); writeToIndex(lang.getLinkageID(), ast, codeReader, ctx, pm); } } catch (CoreException e) { th = e; } catch (RuntimeException e) { final Throwable cause = e.getCause(); if (cause instanceof DependsOnOutdatedFileException) return (DependsOnOutdatedFileException) cause; th = e; } catch (StackOverflowError e) { th = e; } catch (AssertionError e) { th = e; } catch (OutOfMemoryError e) { if (--fSwallowOutOfMemoryError < 0) throw e; th = e; } if (th != null) { swallowError(path, th); } return null; }