private int countNonExternalizedStrings(NLSLine line){ int result= 0; NLSElement[] elements= line.getElements(); for (int i= 0; i < elements.length; i++){ if (! elements[i].hasTag()) result++; } return result; }
private static NLSElement findElement(NLSLine line, int position) { NLSElement[] elements= line.getElements(); for (int i= 0; i < elements.length; i++) { NLSElement element= elements[i]; if (isPositionInElement(element, position)) return element; } return null; }
private int countNonExternalizedStrings(NLSLine line){ int result= 0; NLSElement[] elements= line.getElements(); for (int i= 0; i < elements.length; i++){ if (! elements[i].hasTag()) result++; } return result; }
private static NLSElement findElement(NLSLine line, int position) { NLSElement[] elements= line.getElements(); for (int i= 0; i < elements.length; i++) { NLSElement element= elements[i]; if (isPositionInElement(element, position)) return element; } return null; }
private static NLSElement findElement(NLSLine line, int position) { NLSElement[] elements= line.getElements(); for (int i= 0; i < elements.length; i++) { NLSElement element= elements[i]; if (isPositionInElement(element, position)) return element; } return null; }
private int countNonExternalizedStrings(NLSLine line){ int result= 0; NLSElement[] elements= line.getElements(); for (int i= 0; i < elements.length; i++){ if (! elements[i].hasTag()) result++; } return result; }
private int countNonExternalizedStrings(NLSLine line){ int result= 0; NLSElement[] elements= line.getElements(); for (int i= 0; i < elements.length; i++){ if (! elements[i].hasTag()) result++; } return result; }
private int countNonExternalizedStrings(NLSLine line){ int result= 0; NLSElement[] elements= line.getElements(); for (int i= 0; i < elements.length; i++){ if (! elements[i].hasTag()) result++; } return result; }
private static NLSElement findElement(NLSLine line, int position) { NLSElement[] elements= line.getElements(); for (int i= 0; i < elements.length; i++) { NLSElement element= elements[i]; if (isPositionInElement(element, position)) return element; } return null; }
private static NLSElement findElement(NLSLine line, int position) { NLSElement[] elements= line.getElements(); for (int i= 0; i < elements.length; i++) { NLSElement element= elements[i]; if (isPositionInElement(element, position)) return element; } return null; }
private static NLSElement findElement(NLSLine line, int position) { NLSElement[] elements= line.getElements(); for (int i= 0; i < elements.length; i++) { NLSElement element= elements[i]; if (isPositionInElement(element, position)) return element; } return null; }
private int countNonExternalizedStrings(NLSLine line){ int result= 0; NLSElement[] elements= line.getElements(); for (int i= 0; i < elements.length; i++){ if (! elements[i].hasTag()) result++; } return result; }
private static AccessorClassReference findFirstAccessorReference(NLSLine[] lines, CompilationUnit astRoot) { for (int i= 0; i < lines.length; i++) { NLSElement[] elements= lines[i].getElements(); for (int j= 0; j < elements.length; j++) { NLSElement nlsElement= elements[j]; if (nlsElement.hasTag()) { AccessorClassReference accessorClassReference= NLSHintHelper.getAccessorClassReference(astRoot, nlsElement); if (accessorClassReference != null) { return accessorClassReference; } } } } // try to find a access with missing //non-nls tag (bug 75155) for (int i= 0; i < lines.length; i++) { NLSElement[] elements= lines[i].getElements(); for (int j= 0; j < elements.length; j++) { NLSElement nlsElement= elements[j]; if (!nlsElement.hasTag()) { AccessorClassReference accessorClassReference= NLSHintHelper.getAccessorClassReference(astRoot, nlsElement); if (accessorClassReference != null) { return accessorClassReference; } } } } return null; }
/** * Creates and returns an NLS tag edit for a string that is at the specified position in * a compilation unit. Returns <code>null</code> if the string is already NLSed * or the edit could not be created for some other reason. * @throws CoreException */ public static TextEdit createNLSEdit(ICompilationUnit cu, int position) throws CoreException { NLSLine nlsLine= scanCurrentLine(cu, position); if (nlsLine == null) return null; NLSElement element= findElement(nlsLine, position); if (element.hasTag()) return null; NLSElement[] elements= nlsLine.getElements(); int indexInElementList= Arrays.asList(elements).indexOf(element); int editOffset= computeInsertOffset(elements, indexInElementList, cu); String editText= ' ' + NLSElement.createTagText(indexInElementList + 1); //tags are 1-based return new InsertEdit(editOffset, editText); }
/** * Creates and returns an NLS tag edit for a string that is at the specified position in a * compilation unit. * * @param cu the compilation unit * @param position position of the string * @return the edit, or <code>null</code> if the string is already NLSed or the edit could not * be created for some other reason. * @throws CoreException if scanning fails */ public static TextEdit createNLSEdit(ICompilationUnit cu, int position) throws CoreException { NLSLine nlsLine= scanCurrentLine(cu, position); if (nlsLine == null) return null; NLSElement element= findElement(nlsLine, position); if (element.hasTag()) return null; NLSElement[] elements= nlsLine.getElements(); int indexInElementList= Arrays.asList(elements).indexOf(element); int editOffset= computeInsertOffset(elements, indexInElementList, cu); String editText= ' ' + NLSElement.createTagText(indexInElementList + 1); //tags are 1-based return new InsertEdit(editOffset, editText); }
/** * Creates and returns an NLS tag edit for a string that is at the specified position in a * compilation unit. * * @param cu the compilation unit * @param position position of the string * @return the edit, or <code>null</code> if the string is already NLSed or the edit could not * be created for some other reason. * @throws CoreException if scanning fails */ public static TextEdit createNLSEdit(ICompilationUnit cu, int position) throws CoreException { NLSLine nlsLine= scanCurrentLine(cu, position); if (nlsLine == null) return null; NLSElement element= findElement(nlsLine, position); if (element.hasTag()) return null; NLSElement[] elements= nlsLine.getElements(); int indexInElementList= Arrays.asList(elements).indexOf(element); int editOffset= computeInsertOffset(elements, indexInElementList, cu); String editText= ' ' + NLSElement.createTagText(indexInElementList + 1); //tags are 1-based return new InsertEdit(editOffset, editText); }
private NLSSubstitution[] createSubstitutions(NLSLine[] lines, Properties props, CompilationUnit astRoot) { List<NLSSubstitution> result= new ArrayList<>(); for (int i= 0; i < lines.length; i++) { NLSElement[] elements= lines[i].getElements(); for (int j= 0; j < elements.length; j++) { NLSElement nlsElement= elements[j]; if (nlsElement.hasTag()) { AccessorClassReference accessorClassReference= NLSHintHelper.getAccessorClassReference(astRoot, nlsElement); if (accessorClassReference == null) { // no accessor class => not translated result.add(new NLSSubstitution(NLSSubstitution.IGNORED, stripQuotes(nlsElement.getValue()), nlsElement)); } else { String key= stripQuotes(nlsElement.getValue()); String value= props.getProperty(key); result.add(new NLSSubstitution(NLSSubstitution.EXTERNALIZED, key, value, nlsElement, accessorClassReference)); } } else if (nlsElement.isEclipseNLS()) { String key= nlsElement.getValue(); result.add(new NLSSubstitution(NLSSubstitution.EXTERNALIZED, key, props.getProperty(key), nlsElement, nlsElement.getAccessorClassReference())); } else { result.add(new NLSSubstitution(NLSSubstitution.INTERNALIZED, stripQuotes(nlsElement.getValue()), nlsElement)); } } } return result.toArray(new NLSSubstitution[result.size()]); }
private static void setTagPositions(IDocument document, NLSLine line) throws BadLocationException { IRegion info= document.getLineInformation(line.getLineNumber()); int defaultValue= info.getOffset() + info.getLength(); NLSElement[] elements= line.getElements(); for (int i= 0; i < elements.length; i++) { NLSElement element= elements[i]; if (!element.hasTag()) { element.setTagPosition(computeInsertOffset(elements, i, defaultValue), 0); } } }
private static void setTagPositions(IDocument document, NLSLine line) throws BadLocationException { IRegion info= document.getLineInformation(line.getLineNumber()); int defaultValue= info.getOffset() + info.getLength(); NLSElement[] elements= line.getElements(); for (int i= 0; i < elements.length; i++) { NLSElement element= elements[i]; if (!element.hasTag()) { element.setTagPosition(computeInsertOffset(elements, i, defaultValue), 0); } } }
private static void setTagPositions(IDocument document, NLSLine line) throws BadLocationException { IRegion info= document.getLineInformation(line.getLineNumber()); int defaultValue= info.getOffset() + info.getLength(); NLSElement[] elements= line.getElements(); for (int i= 0; i < elements.length; i++) { NLSElement element= elements[i]; if (!element.hasTag()) { element.setTagPosition(computeInsertOffset(elements, i, defaultValue), 0); } } }