public static Change create(ICompilationUnit cu, String accessorClassname, IPath accessorPath, IPackageFragment accessorPackage, IPath resourceBundlePath, boolean isEclipseNLS, NLSSubstitution[] nlsSubstitutions, String substitutionPattern, IProgressMonitor pm) throws CoreException { AccessorClassCreator accessorClass= new AccessorClassCreator(cu, accessorClassname, accessorPath, accessorPackage, resourceBundlePath, isEclipseNLS, nlsSubstitutions, substitutionPattern); return new CreateTextFileChange(accessorPath, accessorClass.createAccessorCUSource(pm), null, "java"); //$NON-NLS-1$ }
int initIdx= sortOrder.getCategoryIndex(MembersOrderPreferenceCache.STATIC_INIT_INDEX); String constructor= createConstructor(lineDelim) + lineDelim; String initializer= createStaticInitializer(lineDelim) + lineDelim; String fields= createStaticFields(lineDelim) + lineDelim; result.append("private static final String ").append(NLSRefactoring.BUNDLE_NAME).append(" = \"").append(getResourceBundleName()).append("\"; "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ result.append(NLSElement.createTagText(1)).append(lineDelim); int methodIdx= sortOrder.getCategoryIndex(MembersOrderPreferenceCache.METHOD_INDEX); String constructor= lineDelim + createConstructor(lineDelim); String method= lineDelim + createGetStringMethod(lineDelim); result.append(" = \"").append(getResourceBundleName()).append("\"; ").append(NLSElement.createTagText(1)).append(lineDelim); //$NON-NLS-1$ //$NON-NLS-2$ result.append(lineDelim).append("private static final ResourceBundle ").append(getResourceBundleConstantName()); //$NON-NLS-1$ result.append("= ResourceBundle.getBundle(").append(NLSRefactoring.BUNDLE_NAME).append(");").append(lineDelim); //$NON-NLS-1$ //$NON-NLS-2$
fileComment= CodeGeneration.getFileComment(newCu, lineDelim); String classContent= createClass(lineDelim); String cuContent= CodeGeneration.getCompilationUnitContent(newCu, fileComment, typeComment, classContent, lineDelim); if (cuContent == null) { addImportsToAccessorCu(newCu, pm); return newCu.getSource(); } finally {
private String createStaticFields() { HashSet<String> added= new HashSet<>(); List<NLSSubstitution> subs= new ArrayList<>(); for (int i= 0; i < fNLSSubstitutions.length; i++) { NLSSubstitution substitution= fNLSSubstitutions[i]; int newState= substitution.getState(); if ((substitution.hasStateChanged() || substitution.isAccessorRename())&& newState == NLSSubstitution.EXTERNALIZED) { if (added.add(substitution.getKey())) subs.add(substitution); } } Collections.sort(subs, new Comparator<NLSSubstitution>() { private Collator fCollator= Collator.getInstance(); @Override public int compare(NLSSubstitution s0, NLSSubstitution s1) { return fCollator.compare(s0.getKey(), s1.getKey()); } }); StringBuffer buf= new StringBuffer(); for (Iterator<NLSSubstitution> iter= subs.iterator(); iter.hasNext();) { NLSSubstitution element= iter.next(); appendStaticField(buf, element); } return buf.toString(); }
result.add(AccessorClassCreator.create(fCu, fAccessorClassName, getAccessorCUPath(), fAccessorClassPackage, getPropertyFilePath(), fIsEclipseNLS, fSubstitutions, getSubstitutionPattern(), new SubProgressMonitor(pm, 1)));
int initIdx= sortOrder.getCategoryIndex(MembersOrderPreferenceCache.STATIC_INIT_INDEX); String constructor= createConstructor(lineDelim) + lineDelim; String initializer= createStaticInitializer(lineDelim) + lineDelim; String fields= createStaticFields() + lineDelim; result.append("private static final String ").append(NLSRefactoring.BUNDLE_NAME_FIELD).append(" = \"").append(getResourceBundleName()).append("\"; "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ result.append(NLSElement.createTagText(1)).append(lineDelim); int methodIdx= sortOrder.getCategoryIndex(MembersOrderPreferenceCache.METHOD_INDEX); String constructor= lineDelim + createConstructor(lineDelim); String method= lineDelim + createGetStringMethod(lineDelim); result.append(" = \"").append(getResourceBundleName()).append("\"; ").append(NLSElement.createTagText(1)).append(lineDelim); //$NON-NLS-1$ //$NON-NLS-2$ result.append(lineDelim).append("private static final ResourceBundle ").append(getResourceBundleConstantName()); //$NON-NLS-1$ result.append("= ResourceBundle.getBundle(").append(NLSRefactoring.BUNDLE_NAME_FIELD).append(");").append(lineDelim); //$NON-NLS-1$ //$NON-NLS-2$
fileComment= CodeGeneration.getFileComment(newCu, lineDelim); String classContent= createClass(lineDelim); String cuContent= CodeGeneration.getCompilationUnitContent(newCu, fileComment, typeComment, classContent, lineDelim); if (cuContent == null) { addImportsToAccessorCu(newCu, pm); return newCu.getSource(); } finally {
private String createStaticFields() { HashSet<String> added= new HashSet<>(); List<NLSSubstitution> subs= new ArrayList<>(); for (int i= 0; i < fNLSSubstitutions.length; i++) { NLSSubstitution substitution= fNLSSubstitutions[i]; int newState= substitution.getState(); if ((substitution.hasStateChanged() || substitution.isAccessorRename())&& newState == NLSSubstitution.EXTERNALIZED) { if (added.add(substitution.getKey())) subs.add(substitution); } } Collections.sort(subs, new Comparator<NLSSubstitution>() { private Collator fCollator= Collator.getInstance(); @Override public int compare(NLSSubstitution s0, NLSSubstitution s1) { return fCollator.compare(s0.getKey(), s1.getKey()); } }); StringBuilder buf= new StringBuilder(); for (Iterator<NLSSubstitution> iter= subs.iterator(); iter.hasNext();) { NLSSubstitution element= iter.next(); appendStaticField(buf, element); } return buf.toString(); }
result.add(AccessorClassCreator.create(fCu, fAccessorClassName, getAccessorCUPath(), fAccessorClassPackage, getPropertyFilePath(), fIsEclipseNLS, fSubstitutions, getSubstitutionPattern(), new SubProgressMonitor(pm, 1)));
int initIdx= sortOrder.getCategoryIndex(MembersOrderPreferenceCacheCommon.STATIC_INIT_INDEX); String constructor= createConstructor(lineDelim) + lineDelim; String initializer= createStaticInitializer(lineDelim) + lineDelim; String fields= createStaticFields() + lineDelim; result.append("private static final String ").append(NLSRefactoring.BUNDLE_NAME_FIELD).append(" = \"").append(getResourceBundleName()).append("\"; "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ result.append(NLSElement.createTagText(1)).append(lineDelim); int methodIdx= sortOrder.getCategoryIndex(MembersOrderPreferenceCacheCommon.METHOD_INDEX); String constructor= lineDelim + createConstructor(lineDelim); String method= lineDelim + createGetStringMethod(lineDelim); result.append(" = \"").append(getResourceBundleName()).append("\"; ").append(NLSElement.createTagText(1)).append(lineDelim); //$NON-NLS-1$ //$NON-NLS-2$ result.append(lineDelim).append("private static final ResourceBundle ").append(getResourceBundleConstantName()); //$NON-NLS-1$ result.append("= ResourceBundle.getBundle(").append(NLSRefactoring.BUNDLE_NAME_FIELD).append(");").append(lineDelim); //$NON-NLS-1$ //$NON-NLS-2$
public static Change create(ICompilationUnit cu, String accessorClassname, IPath accessorPath, IPackageFragment accessorPackage, IPath resourceBundlePath, boolean isEclipseNLS, NLSSubstitution[] nlsSubstitutions, String substitutionPattern, IProgressMonitor pm) throws CoreException { AccessorClassCreator accessorClass= new AccessorClassCreator(cu, accessorClassname, accessorPath, accessorPackage, resourceBundlePath, isEclipseNLS, nlsSubstitutions, substitutionPattern); return new CreateTextFileChange(accessorPath, accessorClass.createAccessorCUSource(pm), null, "java"); //$NON-NLS-1$ }
fileComment= CodeGeneration.getFileComment(newCu, lineDelim); String classContent= createClass(lineDelim); String cuContent= CodeGeneration.getCompilationUnitContent(newCu, fileComment, typeComment, classContent, lineDelim); if (cuContent == null) { addImportsToAccessorCu(newCu, pm); return newCu.getSource(); } finally {
private String createStaticFields(String lineDelim) { HashSet added= new HashSet(); List subs= new ArrayList(); for (int i= 0; i < fNLSSubstitutions.length; i++) { NLSSubstitution substitution= fNLSSubstitutions[i]; int newState= substitution.getState(); if ((substitution.hasStateChanged() || substitution.isAccessorRename())&& newState == NLSSubstitution.EXTERNALIZED) { if (added.add(substitution.getKey())) subs.add(substitution); } } Collections.sort(subs, new Comparator() { private Collator fCollator= Collator.getInstance(); public int compare(Object o1, Object o2) { NLSSubstitution s0= (NLSSubstitution)o1; NLSSubstitution s1= (NLSSubstitution)o2; return fCollator.compare(s0.getKey(), s1.getKey()); } }); StringBuffer buf= new StringBuffer(); for (Iterator iter= subs.iterator(); iter.hasNext();) { NLSSubstitution element= (NLSSubstitution)iter.next(); appendStaticField(buf, element); } return buf.toString(); }
result.add(AccessorClassCreator.create(fCu, fAccessorClassName, getAccessorCUPath(), fAccessorClassPackage, getPropertyFilePath(), fIsEclipseNLS, fSubstitutions, getSubstitutionPattern(), new SubProgressMonitor(pm, 1)));
public static Change create(ICompilationUnit cu, String accessorClassname, IPath accessorPath, IPackageFragment accessorPackage, IPath resourceBundlePath, boolean isEclipseNLS, NLSSubstitution[] nlsSubstitutions, String substitutionPattern, IProgressMonitor pm) throws CoreException { AccessorClassCreator accessorClass= new AccessorClassCreator(cu, accessorClassname, accessorPath, accessorPackage, resourceBundlePath, isEclipseNLS, nlsSubstitutions, substitutionPattern); return new CreateTextFileChange(accessorPath, accessorClass.createAccessorCUSource(pm), null, "java"); //$NON-NLS-1$ }