Skip to content

Commit

Permalink
Fix netbeans warnings, white-space problems
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasblaesing committed Feb 22, 2020
1 parent 74a5e17 commit 24dbd0e
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 126 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public class CssIndexer extends EmbeddingIndexer {
/**
* For firing index changes out of the parsing thread.
*/
private static RequestProcessor RP = new RequestProcessor();
private static final RequestProcessor RP = new RequestProcessor();

private static final Logger LOGGER = Logger.getLogger(CssIndexer.class.getSimpleName());
private static final boolean LOG = LOGGER.isLoggable(Level.FINE);

Expand All @@ -69,16 +69,13 @@ public class CssIndexer extends EmbeddingIndexer {
public static final String COLORS_KEY = "colors"; //NOI18N

public static final char VIRTUAL_ELEMENT_MARKER = '!'; //NOI18N

//used during the indexing (content is mutable)
private static final Map<FileObject, AtomicLong> importsHashCodes = new HashMap<>();

//final version used after the indexing finishes (immutable)
private static Map<FileObject, AtomicLong> computedImportsHashCodes = new HashMap<>();

// static {
// LOG.setLevel(Level.ALL);
// }

@Override
protected void index(Indexable indexable, Result parserResult, Context context) {
try {
Expand All @@ -96,7 +93,7 @@ protected void index(Indexable indexable, Result parserResult, Context context)
storeEntries(model.getClasses(), document, CLASSES_KEY);
storeEntries(model.getHtmlElements(), document, HTML_ELEMENTS_KEY);
storeEntries(model.getColors(), document, COLORS_KEY);

//support for caching the file dependencies
int entriesHashCode = storeEntries(model.getImports(), document, IMPORTS_KEY);
FileObject root = context.getRoot();
Expand All @@ -105,10 +102,10 @@ protected void index(Indexable indexable, Result parserResult, Context context)
if (aggregatedHash == null) {
aggregatedHash = new AtomicLong(0);
importsHashCodes.put(root, aggregatedHash);
}
}
aggregatedHash.set(aggregatedHash.get() * 79 + entriesHashCode);
}

//this is a marker key so it's possible to find
//all stylesheets easily
document.addPair(CSS_CONTENT_KEY, Boolean.TRUE.toString(), true, true);
Expand All @@ -117,14 +114,14 @@ protected void index(Indexable indexable, Result parserResult, Context context)
for(CssIndexModel indexModel : indexModels) {
indexModel.storeToIndex(document);
}

support.addDocument(document);

} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}

//1. no synchronization on the computedImportsHashCodes!
//2. the callers of this method will get old results if an indexing is in progress and
// if the cached hashcode changes - possibly add some kind of synchronization
Expand All @@ -142,7 +139,7 @@ public static long getImportsHashCodeForRoots(Collection<FileObject> roots) {

private int storeEntries(Collection<Entry> entries, IndexDocument doc, String key) {
if (!entries.isEmpty()) {

//eliminate duplicated entries
Set<String> entryStrings = new TreeSet<>();
for(Entry entry : entries) {
Expand All @@ -161,17 +158,12 @@ private int storeEntries(Collection<Entry> entries, IndexDocument doc, String ke
}
return 0;
}

private static void fireChange(final FileObject fo) {
// handle events firing in separate thread:
RP.post(new Runnable() {
@Override
public void run() {
fireChangeImpl(fo);
}
});
RP.post(() -> fireChangeImpl(fo));
}

static private void fireChangeImpl(FileObject fo) {
Project p = FileOwnerQuery.getOwner(fo);
if (p == null) {
Expand Down Expand Up @@ -201,7 +193,7 @@ public EmbeddingIndexer createIndexer(Indexable indexable, Snapshot snapshot) {
return null;
}
}

@Override
public boolean scanStarted(Context context) {
synchronized(importsHashCodes) {
Expand All @@ -210,7 +202,6 @@ public boolean scanStarted(Context context) {
return super.scanStarted(context);
}


@Override
public void scanFinished(Context context) {
synchronized(importsHashCodes) {
Expand Down
Loading

0 comments on commit 24dbd0e

Please sign in to comment.