use of org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileDefine in project linuxtools by eclipse.
the class SpecfileDefineTest method testDefine.
@Test
public void testDefine() {
SpecfileDefine blahDefine = specfile.getDefine("blah");
assertEquals(SpecfileDefine.class, blahDefine.getClass());
assertEquals("blah", blahDefine.getName());
assertEquals("bleh", blahDefine.getStringValue());
}
use of org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileDefine in project linuxtools by eclipse.
the class SpecfileDefineTest method testDefine2.
@Test
public void testDefine2() {
SpecfileDefine blahDefine = specfile.getDefine("blah2");
assertEquals(SpecfileDefine.class, blahDefine.getClass());
assertEquals("blah2", blahDefine.getName());
assertEquals("bleh", blahDefine.getStringValue());
}
use of org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileDefine in project linuxtools by eclipse.
the class SpecfileDefineTest method testResolve.
@Test
public void testResolve() {
SpecfileDefine define1 = new SpecfileDefine("name", "testspec", specfile, specfile.getPackages().getPackage(specfile.getName()));
specfile.addDefine(define1);
assertEquals("testspec", ((SpecfileElement) define1).resolve("%{name}"));
}
use of org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileDefine in project linuxtools by eclipse.
the class SpecfileDefineTest method testDefine3.
@Test
public void testDefine3() {
SpecfileDefine blahDefine = specfile.getDefine("blah3");
assertEquals(SpecfileDefine.class, blahDefine.getClass());
assertEquals("blah3", blahDefine.getName());
assertEquals(1, blahDefine.getIntValue());
}
use of org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileDefine in project linuxtools by eclipse.
the class RpmMacroOccurrencesUpdater method update.
/**
* Updates the drawn annotations.
*
* @param viewer
* The viewer to get the document and annotation model from
*/
public void update(ISourceViewer viewer) {
try {
IDocument document = viewer.getDocument();
IAnnotationModel model = viewer.getAnnotationModel();
if (document == null || model == null) {
return;
}
removeOldAnnotations(model);
String currentSelectedWord = getWordAtSelection(fEditor.getSelectionProvider().getSelection(), document);
if (isMacro(currentSelectedWord)) {
Specfile spec = fEditor.getSpecfile();
SpecfileDefine define = spec.getDefine(currentSelectedWord);
// $NON-NLS-1$
String word = currentSelectedWord + ": ";
if (define != null) {
word += define.getStringValue();
} else {
// If there's no such define we try to see if it corresponds
// to
// a Source or Patch declaration
String retrivedValue = RPMUtils.getSourceOrPatchValue(spec, currentSelectedWord.toLowerCase());
if (retrivedValue != null) {
word += retrivedValue;
} else {
// If it does not correspond to a Patch or Source macro,
// try to find it
// in the macro proposals list.
retrivedValue = RPMUtils.getMacroValueFromMacroList(currentSelectedWord);
if (retrivedValue != null) {
word += retrivedValue;
}
}
}
createNewAnnotations(currentSelectedWord, word, document, model);
}
} catch (BadLocationException e) {
SpecfileLog.logError(e);
}
}
Aggregations