src/share/classes/com/sun/tools/javac/processing/JavacMessager.java

changeset 1258
d10db3576c08
parent 798
4868a36f6fd8
child 2525
2eb010b6cb22
equal deleted inserted replaced
1254:5891b38985e8 1258:d10db3576c08
1 /* 1 /*
2 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this 7 * published by the Free Software Foundation. Oracle designates this
97 JavacElements elemUtils = processingEnv.getElementUtils(); 97 JavacElements elemUtils = processingEnv.getElementUtils();
98 Pair<JCTree, JCCompilationUnit> treeTop = elemUtils.getTreeAndTopLevel(e, a, v); 98 Pair<JCTree, JCCompilationUnit> treeTop = elemUtils.getTreeAndTopLevel(e, a, v);
99 if (treeTop != null) { 99 if (treeTop != null) {
100 newSource = treeTop.snd.sourcefile; 100 newSource = treeTop.snd.sourcefile;
101 if (newSource != null) { 101 if (newSource != null) {
102 // save the old version and reinstate it later
102 oldSource = log.useSource(newSource); 103 oldSource = log.useSource(newSource);
103 pos = treeTop.fst.pos(); 104 pos = treeTop.fst.pos();
104 } 105 }
105 } 106 }
106 try { 107 try {
129 default: 130 default:
130 log.note(pos, "proc.messager", msg.toString()); 131 log.note(pos, "proc.messager", msg.toString());
131 break; 132 break;
132 } 133 }
133 } finally { 134 } finally {
134 if (oldSource != null) 135 // reinstate the saved version, only if it was saved earlier
136 if (newSource != null)
135 log.useSource(oldSource); 137 log.useSource(oldSource);
136 } 138 }
137 } 139 }
138 140
139 /** 141 /**

mercurial