document.setInitialLineDelimiter(getLineDelimiterUsed(cu)); change= new DocumentChange(name, document);
public static Change create(NLSSubstitution[] nlsSubstitutions, IPath propertyFilePath) throws CoreException { String name= Messages.format(NLSMessages.NLSPropertyFileModifier_change_name, propertyFilePath.toString()); TextChange textChange= null; if (!Checks.resourceExists(propertyFilePath)) { IProject project= getFileHandle(propertyFilePath).getProject(); String lineDelimiter= StubUtility.getLineDelimiterPreference(project); Document document= new Document(); document.setInitialLineDelimiter(lineDelimiter); textChange= new DocumentChange(name, document); addChanges(textChange, nlsSubstitutions); textChange.perform(new NullProgressMonitor()); String encoding= null; IContentType javaPropertiesContentType= Platform.getContentTypeManager().getContentType("org.eclipse.jdt.core.javaProperties"); //$NON-NLS-1$ IContentType[] contentTypes= Platform.getContentTypeManager().findContentTypesFor(propertyFilePath.lastSegment()); if (contentTypes.length == 0 || contentTypes.length > 1 || !contentTypes[0].equals(javaPropertiesContentType)) { if (javaPropertiesContentType != null) encoding= javaPropertiesContentType.getDefaultCharset(); if (encoding == null) encoding= "ISO-8859-1"; //$NON-NLS-1$ } return new CreateTextFileChange(propertyFilePath, textChange.getCurrentContent(new NullProgressMonitor()), encoding, "properties"); //$NON-NLS-1$ } textChange= new TextFileChange(name, getPropertyFile(propertyFilePath)); textChange.setTextType("properties"); //$NON-NLS-1$ addChanges(textChange, nlsSubstitutions); return textChange; }
public static Change create(NLSSubstitution[] nlsSubstitutions, IPath propertyFilePath) throws CoreException { String name= Messages.format(NLSMessages.NLSPropertyFileModifier_change_name, BasicElementLabels.getPathLabel(propertyFilePath, false)); TextChange textChange= null; if (!Checks.resourceExists(propertyFilePath)) { IProject project= getFileHandle(propertyFilePath).getProject(); String lineDelimiter= StubUtility.getLineDelimiterPreference(project); Document document= new Document(); document.setInitialLineDelimiter(lineDelimiter); textChange= new DocumentChange(name, document); addChanges(textChange, nlsSubstitutions); textChange.perform(new NullProgressMonitor()); String encoding= null; IContentType javaPropertiesContentType= Platform.getContentTypeManager().getContentType("org.eclipse.jdt.core.javaProperties"); //$NON-NLS-1$ IContentType[] contentTypes= Platform.getContentTypeManager().findContentTypesFor(propertyFilePath.lastSegment()); if (contentTypes.length == 0 || contentTypes.length > 1 || !contentTypes[0].equals(javaPropertiesContentType)) { if (javaPropertiesContentType != null) encoding= javaPropertiesContentType.getDefaultCharset(); if (encoding == null) encoding= "ISO-8859-1"; //$NON-NLS-1$ } return new CreateTextFileChange(propertyFilePath, textChange.getCurrentContent(new NullProgressMonitor()), encoding, "properties"); //$NON-NLS-1$ } textChange= new TextFileChange(name, getPropertyFile(propertyFilePath)); textChange.setTextType("properties"); //$NON-NLS-1$ addChanges(textChange, nlsSubstitutions); return textChange; }
public static Change create(NLSSubstitution[] nlsSubstitutions, IPath propertyFilePath) throws CoreException { String name= Messages.format(NLSMessages.NLSPropertyFileModifier_change_name, BasicElementLabels.getPathLabel(propertyFilePath, false)); TextChange textChange= null; if (!Checks.resourceExists(propertyFilePath)) { IProject project= getFileHandle(propertyFilePath).getProject(); String lineDelimiter= StubUtility.getLineDelimiterPreference(project); Document document= new Document(); document.setInitialLineDelimiter(lineDelimiter); textChange= new DocumentChange(name, document); addChanges(textChange, nlsSubstitutions); textChange.perform(new NullProgressMonitor()); String encoding= null; IContentType javaPropertiesContentType= Platform.getContentTypeManager().getContentType("org.eclipse.jdt.core.javaProperties"); //$NON-NLS-1$ IContentType[] contentTypes= Platform.getContentTypeManager().findContentTypesFor(propertyFilePath.lastSegment()); if (contentTypes.length == 0 || contentTypes.length > 1 || !contentTypes[0].equals(javaPropertiesContentType)) { if (javaPropertiesContentType != null) encoding= javaPropertiesContentType.getDefaultCharset(); if (encoding == null) encoding= "ISO-8859-1"; //$NON-NLS-1$ } return new CreateTextFileChange(propertyFilePath, textChange.getCurrentContent(new NullProgressMonitor()), encoding, "properties"); //$NON-NLS-1$ } textChange= new TextFileChange(name, getPropertyFile(propertyFilePath)); textChange.setTextType("properties"); //$NON-NLS-1$ addChanges(textChange, nlsSubstitutions); return textChange; }
document.setInitialLineDelimiter(StubUtility.getLineDelimiterUsed(cu)); change= new DocumentChange(name, document); } else {
public TextChange getNewChange() { ICompilationUnit cu= getCompilationUnit(); String name= getName(); TextChange change; if (!cu.getResource().exists()) { String source; try { source= cu.getSource(); } catch (JavaModelException e) { JavaManipulationPlugin.log(e); source= new String(); // empty } Document document= new Document(source); document.setInitialLineDelimiter(StubUtility.getLineDelimiterUsed(cu)); change= new DocumentChange(name, document); } else { CompilationUnitChange cuChange = new CompilationUnitChange(name, cu); cuChange.setSaveMode(TextFileChange.LEAVE_DIRTY); change= cuChange; } TextEdit rootEdit= new MultiTextEdit(); change.setEdit(rootEdit); return change; }
document.setInitialLineDelimiter(StubUtility.getLineDelimiterUsed(cu)); change= new DocumentChange(name, document); } else {